summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthew Bauer <mjbauer95@gmail.com>2018-07-08 16:09:47 -0400
committerMatthew Bauer <mjbauer95@gmail.com>2018-07-09 12:00:31 -0400
commit7e4ce2cfcbb217bb66e068803b549a4d1fa98673 (patch)
tree88b90a19a981ceba672586edc87b932743f5e551
parentb802570fc249eb2beae4fb5b80f39a8bdbd6c290 (diff)
downloadnixpkgs-7e4ce2cfcbb217bb66e068803b549a4d1fa98673.tar
nixpkgs-7e4ce2cfcbb217bb66e068803b549a4d1fa98673.tar.gz
nixpkgs-7e4ce2cfcbb217bb66e068803b549a4d1fa98673.tar.bz2
nixpkgs-7e4ce2cfcbb217bb66e068803b549a4d1fa98673.tar.lz
nixpkgs-7e4ce2cfcbb217bb66e068803b549a4d1fa98673.tar.xz
nixpkgs-7e4ce2cfcbb217bb66e068803b549a4d1fa98673.tar.zst
nixpkgs-7e4ce2cfcbb217bb66e068803b549a4d1fa98673.zip
unixtools: refactor
-rw-r--r--pkgs/top-level/unix-tools.nix34
1 files changed, 19 insertions, 15 deletions
diff --git a/pkgs/top-level/unix-tools.nix b/pkgs/top-level/unix-tools.nix
index f92e90fed77..3f8fdf7d888 100644
--- a/pkgs/top-level/unix-tools.nix
+++ b/pkgs/top-level/unix-tools.nix
@@ -1,5 +1,4 @@
-{ pkgs, buildEnv, runCommand, hostPlatform, lib
-, stdenv }:
+{ 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,21 +10,25 @@
 # instance, if your program needs to use "ps", just list it as a build
 # input, not "procps" which requires Linux.
 
+with lib;
+
 let
   version = "1003.1-2008";
 
   singleBinary = cmd: providers: let
-      provider = "${lib.getBin providers.${hostPlatform.parsed.kernel.name}}/bin/${cmd}";
-      manpage = "${lib.getOutput "man" providers.${hostPlatform.parsed.kernel.name}}/share/man/man1/${cmd}.1.gz";
+      provider = providers.${hostPlatform.parsed.kernel.name};
+      bin = "${getBin provider}/bin/${cmd}";
+      manpage = "${getOutput "man" provider}/share/man/man1/${cmd}.1.gz";
     in runCommand "${cmd}-${version}" {
-      meta.platforms = map (n: { kernel.name = n; }) (pkgs.lib.attrNames providers);
+      meta.platforms = map (n: { kernel.name = n; }) (attrNames providers);
+      passthru = { inherit provider; };
     } ''
-      if ! [ -x "${provider}" ]; then
+      if ! [ -x "${bin}" ]; then
         echo "Cannot find command ${cmd}"
         exit 1
       fi
 
-      install -D "${provider}" "$out/bin/${cmd}"
+      install -D "${bin}" "$out/bin/${cmd}"
 
       if [ -f "${manpage}" ]; then
         install -D "${manpage}" $out/share/man/man1/${cmd}.1.gz
@@ -33,13 +36,13 @@ let
     '';
 
   # more is unavailable in darwin
-  # just use less
+  # so we 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 {
+  bins = mapAttrs singleBinary {
     # singular binaries
     arp = {
       linux = pkgs.nettools;
@@ -53,12 +56,12 @@ let
       linux = pkgs.utillinux;
     };
     getconf = {
-      linux = if hostPlatform.libc == "glibc" then lib.getBin pkgs.glibc
+      linux = if hostPlatform.libc == "glibc" then pkgs.glibc
               else pkgs.netbsd.getconf;
       darwin = pkgs.darwin.system_cmds;
     };
     getent = {
-      linux = if hostPlatform.libc == "glibc" then lib.getBin pkgs.glibc
+      linux = if hostPlatform.libc == "glibc" then pkgs.glibc
               else pkgs.netbsd.getent;
       darwin = pkgs.netbsd.getent;
     };
@@ -165,10 +168,11 @@ let
     };
   };
 
-  makeCompat = name': value: buildEnv {
-    name = name' + "-compat-${version}";
-    paths = value;
-  };
+  makeCompat = pname: paths:
+    buildEnv {
+      name = "${pname}-${version}";
+      inherit paths;
+    };
 
   # Compatibility derivations
   # Provided for old usage of these commands.