diff options
author | Matthew Bauer <mjbauer95@gmail.com> | 2018-03-25 23:01:31 -0500 |
---|---|---|
committer | Matthew Bauer <mjbauer95@gmail.com> | 2018-03-26 17:40:55 -0500 |
commit | ce8ce600ae41d3899e4a556fa9ff8a1a34374063 (patch) | |
tree | 3ea6538af9f648999a7a68cb44818c52f33963c6 /pkgs/top-level | |
parent | 675dc1bfbfd87c02c8588d78ffc903fb6987f6e4 (diff) | |
download | nixpkgs-ce8ce600ae41d3899e4a556fa9ff8a1a34374063.tar nixpkgs-ce8ce600ae41d3899e4a556fa9ff8a1a34374063.tar.gz nixpkgs-ce8ce600ae41d3899e4a556fa9ff8a1a34374063.tar.bz2 nixpkgs-ce8ce600ae41d3899e4a556fa9ff8a1a34374063.tar.lz nixpkgs-ce8ce600ae41d3899e4a556fa9ff8a1a34374063.tar.xz nixpkgs-ce8ce600ae41d3899e4a556fa9ff8a1a34374063.tar.zst nixpkgs-ce8ce600ae41d3899e4a556fa9ff8a1a34374063.zip |
unix-tools: introduce unix-tools.nix
unix-tools.nix has a collection of tools that are commonly installed by default in Unix derivatives. This is intended to provide compatibility between macOS and Linux users. Three Linux-only derivations are provided for compatbility: - procps - utillinux - nettools More tools are also provided. Also: treewide: use unixtools Non-comprehensive replace of Linux-only procps and util-linux with 'unixtools'.
Diffstat (limited to 'pkgs/top-level')
-rw-r--r-- | pkgs/top-level/all-packages.nix | 21 | ||||
-rw-r--r-- | pkgs/top-level/unix-tools.nix | 89 |
2 files changed, 101 insertions, 9 deletions
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a4726f59b89..e14eb820d72 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12380,12 +12380,7 @@ with pkgs; jetty = callPackage ../servers/http/jetty { }; knot-dns = callPackage ../servers/dns/knot-dns { }; - knot-resolver = callPackage ../servers/dns/knot-resolver { - # TODO: vimNox after it gets fixed on Darwin or something lighter - hexdump = if stdenv.isLinux then utillinux.bin - else if stdenv.isDarwin then darwin.shell_cmds - else vim/*xxd*/; - }; + knot-resolver = callPackage ../servers/dns/knot-resolver { }; rdkafka = callPackage ../development/libraries/rdkafka { }; @@ -13694,7 +13689,8 @@ with pkgs; if hostPlatform.isMusl then musl-getconf else lib.getBin stdenv.cc.libc; - nettools = callPackage ../os-specific/linux/net-tools { }; + nettools = if stdenv.isLinux then callPackage ../os-specific/linux/net-tools { } + else unixtools.nettools; nftables = callPackage ../os-specific/linux/nftables { }; @@ -13817,7 +13813,8 @@ with pkgs; procps = procps-ng; - procps-ng = callPackage ../os-specific/linux/procps-ng { }; + procps-ng = if stdenv.isLinux then callPackage ../os-specific/linux/procps-ng { } + else unixtools.procps; watch = callPackage ../os-specific/linux/procps/watch.nix { }; @@ -14010,7 +14007,9 @@ with pkgs; usermount = callPackage ../os-specific/linux/usermount { }; - utillinux = callPackage ../os-specific/linux/util-linux { }; + utillinux = if stdenv.isLinux then callPackage ../os-specific/linux/util-linux { } + else unixtools.utillinux; + utillinuxCurses = utillinux; utillinuxMinimal = appendToName "minimal" (utillinux.override { @@ -21140,4 +21139,8 @@ with pkgs; xml2rfc = callPackage ../tools/typesetting/xml2rfc { }; mmark = callPackage ../tools/typesetting/mmark { }; + + # Unix tools + unixtools = recurseIntoAttrs (callPackages ./unix-tools.nix { }); + inherit (unixtools) hexdump ps; } diff --git a/pkgs/top-level/unix-tools.nix b/pkgs/top-level/unix-tools.nix new file mode 100644 index 00000000000..706cd061b59 --- /dev/null +++ b/pkgs/top-level/unix-tools.nix @@ -0,0 +1,89 @@ +{ pkgs, buildEnv, runCommand, hostPlatform }: + +let + + singleBinary = cmd: providers: + if builtins.hasAttr hostPlatform.parsed.kernel.name providers then + runCommand cmd {} '' + mkdir -p $out/bin + + if ! [ -x "${providers.${hostPlatform.parsed.kernel.name}}/bin/${cmd}" ]; then + echo "Cannot find command ${cmd}" + exit 1 + fi + + ln -s ${providers.${hostPlatform.parsed.kernel.name}}/bin/${cmd} $out/bin/${cmd} + '' + else throw "${hostPlatform.parsed.kernel.name} does not have ${cmd}"; + +in rec { + arp = singleBinary "arp" { + linux = pkgs.nettools; + darwin = pkgs.darwin.network_cmds; + }; + getopt = singleBinary "getopt" { + linux = pkgs.utillinux; + darwin = pkgs.darwin.shell_cmds; + }; + hexdump = singleBinary "hexdump" { + linux = pkgs.procps; + 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; + }; + 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.adv_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; + }; + whereis = singleBinary "whereis" { + linux = pkgs.utillinux; + darwin = pkgs.darwin.shell_cmds; + }; + write = singleBinary "write" { + linux = pkgs.utillinux; + darwin = pkgs.darwin.basic_cmds; + }; + + # Compatibility derivations + + procps = buildEnv { + name = "procps-compat"; + paths = [ sysctl ps ]; + }; + + utillinux = buildEnv { + name = "utillinux-compat"; + paths = [ getopt hexdump script whereis write ]; + }; + + nettools = buildEnv { + name = "nettools-compat"; + paths = [ arp hostname netstat route ]; + }; +} |