unixtools: refactor for less redundancy
This commit is contained in:
parent
7499e4a5b9
commit
4b93f21ced
|
@ -11,7 +11,6 @@
|
||||||
# input, not "procps" which requires Linux.
|
# input, not "procps" which requires Linux.
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
singleBinary = cmd: providers: let
|
singleBinary = cmd: providers: let
|
||||||
provider = "${lib.getBin providers.${hostPlatform.parsed.kernel.name}}/bin/${cmd}";
|
provider = "${lib.getBin providers.${hostPlatform.parsed.kernel.name}}/bin/${cmd}";
|
||||||
in runCommand cmd {
|
in runCommand cmd {
|
||||||
|
@ -27,8 +26,6 @@ let
|
||||||
ln -s "${provider}" "$out/bin/${cmd}"
|
ln -s "${provider}" "$out/bin/${cmd}"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
in rec {
|
|
||||||
|
|
||||||
# more is unavailable in darwin
|
# more is unavailable in darwin
|
||||||
# just use less
|
# just use less
|
||||||
more_compat = runCommand "more" {} ''
|
more_compat = runCommand "more" {} ''
|
||||||
|
@ -36,117 +33,114 @@ in rec {
|
||||||
ln -s ${pkgs.less}/bin/less $out/bin/more
|
ln -s ${pkgs.less}/bin/less $out/bin/more
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# singular binaries
|
bins = lib.mapAttrs singleBinary {
|
||||||
arp = singleBinary "arp" {
|
# singular binaries
|
||||||
linux = pkgs.nettools;
|
arp = {
|
||||||
darwin = pkgs.darwin.network_cmds;
|
linux = pkgs.nettools;
|
||||||
|
darwin = pkgs.darwin.network_cmds;
|
||||||
|
};
|
||||||
|
col = {
|
||||||
|
linux = pkgs.utillinux;
|
||||||
|
darwin = pkgs.darwin.text_cmds;
|
||||||
|
};
|
||||||
|
eject = {
|
||||||
|
linux = pkgs.utillinux;
|
||||||
|
};
|
||||||
|
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;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
col = singleBinary "col" {
|
|
||||||
linux = pkgs.utillinux;
|
makeCompat = name': value: buildEnv {
|
||||||
darwin = pkgs.darwin.text_cmds;
|
name = name' + "-compat";
|
||||||
};
|
paths = value;
|
||||||
eject = singleBinary "eject" {
|
|
||||||
linux = pkgs.utillinux;
|
|
||||||
};
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# Compatibility derivations
|
# Compatibility derivations
|
||||||
# Provided for old usage of these commands.
|
# Provided for old usage of these commands.
|
||||||
|
compat = with bins; lib.mapAttrs makeCompat {
|
||||||
procps = buildEnv {
|
procps = [ ps sysctl top ];
|
||||||
name = "procps-compat";
|
utillinux = [ fsck fdisk getopt hexdump mount
|
||||||
paths = [ ps sysctl top ];
|
script umount whereis write col ];
|
||||||
|
nettools = [ arp hostname ifconfig netstat route ];
|
||||||
};
|
};
|
||||||
|
in bins // compat
|
||||||
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 ];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user