summary refs log tree commit diff
path: root/pkgs/top-level/unix-tools.nix
diff options
context:
space:
mode:
authorMatthew Bauer <mjbauer95@gmail.com>2018-05-08 09:36:00 -0500
committerMatthew Bauer <mjbauer95@gmail.com>2018-05-08 09:36:00 -0500
commit6748534d83fa05cc6dee0f11bce543f7672b351f (patch)
treea0d303182dd9e0c8ae149316270b732715e9ae64 /pkgs/top-level/unix-tools.nix
parent4f7cdd35d58e3d32ba576e218316b3c835bc508c (diff)
parent3510b983c41196fce90729289c8c300ada1ccaea (diff)
downloadnixpkgs-6748534d83fa05cc6dee0f11bce543f7672b351f.tar
nixpkgs-6748534d83fa05cc6dee0f11bce543f7672b351f.tar.gz
nixpkgs-6748534d83fa05cc6dee0f11bce543f7672b351f.tar.bz2
nixpkgs-6748534d83fa05cc6dee0f11bce543f7672b351f.tar.lz
nixpkgs-6748534d83fa05cc6dee0f11bce543f7672b351f.tar.xz
nixpkgs-6748534d83fa05cc6dee0f11bce543f7672b351f.tar.zst
nixpkgs-6748534d83fa05cc6dee0f11bce543f7672b351f.zip
Merge remote-tracking branch 'upstream/master' into staging
Diffstat (limited to 'pkgs/top-level/unix-tools.nix')
-rw-r--r--pkgs/top-level/unix-tools.nix251
1 files changed, 121 insertions, 130 deletions
diff --git a/pkgs/top-level/unix-tools.nix b/pkgs/top-level/unix-tools.nix
index 9b8fefaf8ba..a73f11e69a4 100644
--- a/pkgs/top-level/unix-tools.nix
+++ b/pkgs/top-level/unix-tools.nix
@@ -1,4 +1,5 @@
-{ pkgs, buildEnv, runCommand, hostPlatform, stdenv, lib }:
+{ 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
@@ -11,28 +12,21 @@
 # input, not "procps" which requires Linux.
 
 let
-
   singleBinary = cmd: providers: let
-      provider = lib.getBin providers.${hostPlatform.parsed.kernel.name};
+      provider = "${lib.getBin providers.${hostPlatform.parsed.kernel.name}}/bin/${cmd}";
     in runCommand cmd {
       meta.platforms = map (n: { kernel.name = n; }) (pkgs.lib.attrNames providers);
     } ''
-      mkdir -p $out/bin $out/share/man/man1
+      mkdir -p $out/bin
 
-      if ! [ -x "${provider}/bin/${cmd}" ]; then
+      if ! [ -x "${provider}" ]; then
         echo "Cannot find command ${cmd}"
         exit 1
       fi
 
-      cp "${provider}/bin/${cmd}" "$out/bin/${cmd}"
-
-      if [ -f "${provider}/share/man/man1/${cmd}.1.gz" ]; then
-        cp "${provider}/share/man/man1/${cmd}.1.gz" "$out/share/man/man1/${cmd}.1.gz"
-      fi
+      ln -s "${provider}" "$out/bin/${cmd}"
     '';
 
-in rec {
-
   # more is unavailable in darwin
   # just use less
   more_compat = runCommand "more" {} ''
@@ -40,127 +34,124 @@ in rec {
     ln -s ${pkgs.less}/bin/less $out/bin/more
   '';
 
-  # singular binaries
-  arp = singleBinary "arp" {
-    linux = pkgs.nettools;
-    darwin = pkgs.darwin.network_cmds;
-  };
-  col = singleBinary "col" {
-    linux = pkgs.utillinux;
-    darwin = pkgs.darwin.text_cmds;
-  };
-  eject = singleBinary "eject" {
-    linux = pkgs.utillinux;
-  };
-  getconf = singleBinary "getconf" {
-    linux = if hostPlatform.isMusl then pkgs.musl-getconf
-            else lib.getBin stdenv.cc.libc;
-    darwin = pkgs.darwin.system_cmds;
-  };
-  getent = singleBinary "getent" {
-    linux = if hostPlatform.isMusl then pkgs.musl-getent
-            # This may not be right on other platforms, but preserves existing behavior
-            else /* if hostPlatform.libc == "glibc" then */ pkgs.glibc.bin;
-  };
-  getopt = singleBinary "getopt" {
-    linux = pkgs.utillinux;
-    darwin = pkgs.getopt;
-  };
-  fdisk = singleBinary "fdisk" {
-    linux = pkgs.utillinux;
-    darwin = pkgs.darwin.diskdev_cmds;
-  };
-  fsck = singleBinary "fsck" {
-    linux = pkgs.utillinux;
-    darwin = pkgs.darwin.diskdev_cmds;
-  };
-  hexdump = singleBinary "hexdump" {
-    linux = pkgs.utillinux;
-    darwin = pkgs.darwin.shell_cmds;
-  };
-  hostname = singleBinary "hostname" {
-    linux = pkgs.nettools;
-    darwin = pkgs.darwin.shell_cmds;
-  };
-  ifconfig = singleBinary "ifconfig" {
-    linux = pkgs.nettools;
-    darwin = pkgs.darwin.network_cmds;
-  };
-  logger = singleBinary "logger" {
-    linux = pkgs.utillinux;
-  };
-  more = singleBinary "more" {
-    linux = pkgs.utillinux;
-    darwin = more_compat;
-  };
-  mount = singleBinary "mount" {
-    linux = pkgs.utillinux;
-    darwin = pkgs.darwin.diskdev_cmds;
+  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 = singleBinary "getconf" {
+      linux = if hostPlatform.isMusl then pkgs.musl-getconf
+              else lib.getBin stdenv.cc.libc;
+      darwin = pkgs.darwin.system_cmds;
+    };
+    getent = {
+      linux = if hostPlatform.isMusl then pkgs.musl-getent
+              # This may not be right on other platforms, but preserves existing behavior
+              else /* if hostPlatform.libc == "glibc" then */ pkgs.glibc.bin;
+    };
+    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;
+    };
+    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;
+    };
   };
-  netstat = singleBinary "netstat" {
-    linux = pkgs.nettools;
-    darwin = pkgs.darwin.network_cmds;
-  };
-  ping = singleBinary "ping" {
-    linux = pkgs.iputils;
-    darwin = pkgs.darwin.network_cmds;
-  };
-  ps = singleBinary "ps" {
-    linux = pkgs.procps;
-    darwin = pkgs.darwin.ps;
-  };
-  quota = singleBinary "quota" {
-    linux = pkgs.linuxquota;
-    darwin = pkgs.darwin.diskdev_cmds;
-  };
-  route = singleBinary "route" {
-    linux = pkgs.nettools;
-    darwin = pkgs.darwin.network_cmds;
-  };
-  script = singleBinary "script" {
-    linux = pkgs.utillinux;
-    darwin = pkgs.darwin.shell_cmds;
-  };
-  sysctl = singleBinary "sysctl" {
-    linux = pkgs.procps;
-    darwin = pkgs.darwin.system_cmds;
-  };
-  top = singleBinary "top" {
-    linux = pkgs.procps;
-    darwin = pkgs.darwin.top;
-  };
-  umount = singleBinary "umount" {
-    linux = pkgs.utillinux;
-    darwin = pkgs.darwin.diskdev_cmds;
-  };
-  whereis = singleBinary "whereis" {
-    linux = pkgs.utillinux;
-    darwin = pkgs.darwin.shell_cmds;
-  };
-  wall = singleBinary "wall" {
-    linux = pkgs.utillinux;
-  };
-  write = singleBinary "write" {
-    linux = pkgs.utillinux;
-    darwin = pkgs.darwin.basic_cmds;
+
+  makeCompat = name': value: buildEnv {
+    name = name' + "-compat";
+    paths = value;
   };
 
   # Compatibility derivations
   # Provided for old usage of these commands.
-
-  procps = buildEnv {
-    name = "procps-compat";
-    paths = [ ps sysctl top ];
-  };
-
-  utillinux = buildEnv {
-    name = "utillinux-compat";
-    paths = [ fsck fdisk getopt hexdump mount
-              script umount whereis write col ];
-  };
-
-  nettools = buildEnv {
-    name = "nettools-compat";
-    paths = [ arp hostname ifconfig netstat route ];
+  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