Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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'.
- Loading branch information
1 parent
675dc1b
commit ce8ce60
Showing
11 changed files
with
119 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ]; | ||
}; | ||
} |