3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/top-level/unix-tools.nix
Orivej Desh 7f3de60758 Merge branch 'master' into staging
* master: (161 commits)
  pcsclite: clean up after #41790
  tor: 0.3.3.6 -> 0.3.3.7
  opae: init at 1.0.0
  tinc: 1.0.33 -> 10.0.34
  tinc_pre: 1.1pre15 -> 1.1pre16
  sit: 0.3.2 -> 0.4.0 (#41863)
  platforms/raspberrypi: enable kernelAutoModules
  libupnp: 1.6.21 -> 1.8.3 (#41684)
  androidStudioPackages.{dev,canary}: 3.2.0.16 -> 3.2.0.17
  tdesktop: 1.3.0 -> 1.3.7
  gns3Packages.{server,gui}{Stable,Preview}: 2.1.6 -> 2.1.7
  aws-sam-cli: init at 0.3.0 (#41877)
  nixos/nat: optional networking.nat.externalInterface (#41864)
  linux: 4.17 -> 4.17.1
  linux: 4.16.14 -> 4.16.15
  linux: 4.14.48 -> 4.14.49
  nixos/unbound: add restart (#41885)
  maintainers/create-azure.sh: remove hydra.nixos.org as binary cache (#41883)
  gshogi: init at 0.5.1 (#41840)
  neovim: add missing libiconv
  ...
2018-06-12 20:41:41 +00:00

162 lines
4.1 KiB
Nix

{ pkgs, buildEnv, runCommand, hostPlatform, lib
, stdenv }:
# These are some unix tools that are commonly included in the /usr/bin
# and /usr/sbin directory under more normal distributions. Along with
# coreutils, these are commonly assumed to be available by build
# systems, but we can't assume they are available. In Nix, we list
# each program by name directly through this unixtools attribute.
# You should always try to use single binaries when available. For
# instance, if your program needs to use "ps", just list it as a build
# input, not "procps" which requires Linux.
let
version = "1003.1-2008";
singleBinary = cmd: providers: let
provider = "${lib.getBin providers.${hostPlatform.parsed.kernel.name}}/bin/${cmd}";
in runCommand "${cmd}-${version}" {
meta.platforms = map (n: { kernel.name = n; }) (pkgs.lib.attrNames providers);
} ''
if ! [ -x "${provider}" ]; then
echo "Cannot find command ${cmd}"
exit 1
fi
install -D "${provider}" "$out/bin/${cmd}"
'';
# more is unavailable in darwin
# just use less
more_compat = runCommand "more-${version}" {} ''
mkdir -p $out/bin
ln -s ${pkgs.less}/bin/less $out/bin/more
'';
bins = lib.mapAttrs singleBinary {
# singular binaries
arp = {
linux = pkgs.nettools;
darwin = pkgs.darwin.network_cmds;
};
col = {
linux = pkgs.utillinux;
darwin = pkgs.darwin.text_cmds;
};
eject = {
linux = pkgs.utillinux;
};
getconf = {
linux = if hostPlatform.libc == "glibc" then lib.getBin pkgs.glibc
else pkgs.netbsd.getconf;
darwin = pkgs.darwin.system_cmds;
};
getent = {
linux = if hostPlatform.libc == "glibc" then lib.getBin pkgs.glibc
else pkgs.netbsd.getent;
darwin = pkgs.netbsd.getent;
};
getopt = {
linux = pkgs.utillinux;
darwin = pkgs.getopt;
};
fdisk = {
linux = pkgs.utillinux;
darwin = pkgs.darwin.diskdev_cmds;
};
fsck = {
linux = pkgs.utillinux;
darwin = pkgs.darwin.diskdev_cmds;
};
hexdump = {
linux = pkgs.utillinux;
darwin = pkgs.darwin.shell_cmds;
};
hostname = {
linux = pkgs.nettools;
darwin = pkgs.darwin.shell_cmds;
};
ifconfig = {
linux = pkgs.nettools;
darwin = pkgs.darwin.network_cmds;
};
locale = {
linux = pkgs.glibc;
darwin = pkgs.netbsd.locale;
};
logger = {
linux = pkgs.utillinux;
};
more = {
linux = pkgs.utillinux;
darwin = more_compat;
};
mount = {
linux = pkgs.utillinux;
darwin = pkgs.darwin.diskdev_cmds;
};
netstat = {
linux = pkgs.nettools;
darwin = pkgs.darwin.network_cmds;
};
ping = {
linux = pkgs.iputils;
darwin = pkgs.darwin.network_cmds;
};
ps = {
linux = pkgs.procps;
darwin = pkgs.darwin.ps;
};
quota = {
linux = pkgs.linuxquota;
darwin = pkgs.darwin.diskdev_cmds;
};
route = {
linux = pkgs.nettools;
darwin = pkgs.darwin.network_cmds;
};
script = {
linux = pkgs.utillinux;
darwin = pkgs.darwin.shell_cmds;
};
sysctl = {
linux = pkgs.procps;
darwin = pkgs.darwin.system_cmds;
};
top = {
linux = pkgs.procps;
darwin = pkgs.darwin.top;
};
umount = {
linux = pkgs.utillinux;
darwin = pkgs.darwin.diskdev_cmds;
};
whereis = {
linux = pkgs.utillinux;
darwin = pkgs.darwin.shell_cmds;
};
wall = {
linux = pkgs.utillinux;
};
write = {
linux = pkgs.utillinux;
darwin = pkgs.darwin.basic_cmds;
};
};
makeCompat = name': value: buildEnv {
name = name' + "-compat-${version}";
paths = value;
};
# Compatibility derivations
# Provided for old usage of these commands.
compat = with bins; lib.mapAttrs makeCompat {
procps = [ ps sysctl top ];
utillinux = [ fsck fdisk getopt hexdump mount
script umount whereis write col ];
nettools = [ arp hostname ifconfig netstat route ];
};
in bins // compat