1 { pkgs, buildEnv, runCommand, lib, stdenv }:
3 # These are some unix tools that are commonly included in the /usr/bin
4 # and /usr/sbin directory under more normal distributions. Along with
5 # coreutils, these are commonly assumed to be available by build
6 # systems, but we can't assume they are available. In Nix, we list
7 # each program by name directly through this unixtools attribute.
9 # You should always try to use single binaries when available. For
10 # instance, if your program needs to use "ps", just list it as a build
11 # input, not "procps" which requires Linux.
16 version = "1003.1-2008";
18 singleBinary = cmd: providers: let
19 provider = providers.${stdenv.hostPlatform.parsed.kernel.name} or providers.linux;
20 bin = "${getBin provider}/bin/${cmd}";
21 manpage = "${getOutput "man" provider}/share/man/man1/${cmd}.1.gz";
22 in runCommand "${cmd}-${provider.name}" {
26 platforms = lib.platforms.${stdenv.hostPlatform.parsed.kernel.name} or lib.platforms.all;
28 passthru = { inherit provider; };
29 preferLocalBuild = true;
31 if ! [ -x ${bin} ]; then
32 echo Cannot find command ${cmd}
37 ln -s ${bin} $out/bin/${cmd}
39 if [ -f ${manpage} ]; then
40 mkdir -p $out/share/man/man1
41 ln -s ${manpage} $out/share/man/man1/${cmd}.1.gz
45 # more is unavailable in darwin
47 more_compat = runCommand "more-${pkgs.less.name}" {} ''
49 ln -s ${pkgs.less}/bin/less $out/bin/more
52 bins = mapAttrs singleBinary {
55 linux = pkgs.nettools;
56 darwin = pkgs.darwin.network_cmds;
59 linux = pkgs.util-linux;
60 darwin = pkgs.darwin.text_cmds;
63 linux = pkgs.util-linux;
64 darwin = pkgs.darwin.text_cmds;
67 linux = pkgs.util-linux;
70 linux = if stdenv.hostPlatform.libc == "glibc" then pkgs.stdenv.cc.libc
71 else pkgs.netbsd.getconf;
72 darwin = pkgs.darwin.system_cmds;
75 linux = if stdenv.hostPlatform.libc == "glibc" then pkgs.stdenv.cc.libc.getent
76 else pkgs.netbsd.getent;
77 darwin = pkgs.netbsd.getent;
80 linux = pkgs.util-linux;
84 linux = pkgs.util-linux;
85 darwin = pkgs.darwin.diskdev_cmds;
88 linux = pkgs.util-linux;
89 darwin = pkgs.darwin.diskdev_cmds;
92 linux = pkgs.util-linux;
93 darwin = pkgs.darwin.shell_cmds;
96 linux = pkgs.nettools;
97 darwin = pkgs.darwin.shell_cmds;
100 linux = pkgs.nettools;
101 darwin = pkgs.darwin.network_cmds;
105 darwin = pkgs.darwin.shell_cmds;
109 darwin = pkgs.darwin.adv_cmds;
112 linux = pkgs.util-linux;
115 linux = pkgs.util-linux;
116 darwin = more_compat;
119 linux = pkgs.util-linux;
120 darwin = pkgs.darwin.diskdev_cmds;
123 linux = pkgs.nettools;
124 darwin = pkgs.darwin.network_cmds;
127 linux = pkgs.iputils;
128 darwin = pkgs.darwin.network_cmds;
132 darwin = pkgs.darwin.ps;
135 linux = pkgs.linuxquota;
136 darwin = pkgs.darwin.diskdev_cmds;
139 linux = pkgs.nettools;
140 darwin = pkgs.darwin.network_cmds;
143 linux = pkgs.util-linux;
144 darwin = pkgs.darwin.shell_cmds;
148 darwin = pkgs.darwin.system_cmds;
152 darwin = pkgs.darwin.top;
155 linux = pkgs.util-linux;
156 darwin = pkgs.darwin.diskdev_cmds;
159 linux = pkgs.util-linux;
160 darwin = pkgs.darwin.shell_cmds;
163 linux = pkgs.util-linux;
168 # watch is the only command from procps that builds currently on
169 # Darwin. Unfortunately no other implementations exist currently!
170 darwin = pkgs.callPackage ../os-specific/linux/procps-ng {};
173 linux = pkgs.util-linux;
174 darwin = pkgs.darwin.basic_cmds;
182 makeCompat = pname: paths:
184 name = "${pname}-${version}";
188 # Compatibility derivations
189 # Provided for old usage of these commands.
190 compat = with bins; lib.mapAttrs makeCompat {
191 procps = [ ps sysctl top watch ];
192 util-linux = [ fsck fdisk getopt hexdump mount
193 script umount whereis write col column ];
194 nettools = [ arp hostname ifconfig netstat route ];