unixtools: refactor
This commit is contained in:
parent
b802570fc2
commit
7e4ce2cfcb
|
@ -1,5 +1,4 @@
|
||||||
{ pkgs, buildEnv, runCommand, hostPlatform, lib
|
{ pkgs, buildEnv, runCommand, hostPlatform, lib, stdenv }:
|
||||||
, stdenv }:
|
|
||||||
|
|
||||||
# These are some unix tools that are commonly included in the /usr/bin
|
# These are some unix tools that are commonly included in the /usr/bin
|
||||||
# and /usr/sbin directory under more normal distributions. Along with
|
# 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
|
# instance, if your program needs to use "ps", just list it as a build
|
||||||
# input, not "procps" which requires Linux.
|
# input, not "procps" which requires Linux.
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
version = "1003.1-2008";
|
version = "1003.1-2008";
|
||||||
|
|
||||||
singleBinary = cmd: providers: let
|
singleBinary = cmd: providers: let
|
||||||
provider = "${lib.getBin providers.${hostPlatform.parsed.kernel.name}}/bin/${cmd}";
|
provider = providers.${hostPlatform.parsed.kernel.name};
|
||||||
manpage = "${lib.getOutput "man" providers.${hostPlatform.parsed.kernel.name}}/share/man/man1/${cmd}.1.gz";
|
bin = "${getBin provider}/bin/${cmd}";
|
||||||
|
manpage = "${getOutput "man" provider}/share/man/man1/${cmd}.1.gz";
|
||||||
in runCommand "${cmd}-${version}" {
|
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}"
|
echo "Cannot find command ${cmd}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
install -D "${provider}" "$out/bin/${cmd}"
|
install -D "${bin}" "$out/bin/${cmd}"
|
||||||
|
|
||||||
if [ -f "${manpage}" ]; then
|
if [ -f "${manpage}" ]; then
|
||||||
install -D "${manpage}" $out/share/man/man1/${cmd}.1.gz
|
install -D "${manpage}" $out/share/man/man1/${cmd}.1.gz
|
||||||
|
@ -33,13 +36,13 @@ let
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# more is unavailable in darwin
|
# more is unavailable in darwin
|
||||||
# just use less
|
# so we just use less
|
||||||
more_compat = runCommand "more-${version}" {} ''
|
more_compat = runCommand "more-${version}" {} ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
ln -s ${pkgs.less}/bin/less $out/bin/more
|
ln -s ${pkgs.less}/bin/less $out/bin/more
|
||||||
'';
|
'';
|
||||||
|
|
||||||
bins = lib.mapAttrs singleBinary {
|
bins = mapAttrs singleBinary {
|
||||||
# singular binaries
|
# singular binaries
|
||||||
arp = {
|
arp = {
|
||||||
linux = pkgs.nettools;
|
linux = pkgs.nettools;
|
||||||
|
@ -53,12 +56,12 @@ let
|
||||||
linux = pkgs.utillinux;
|
linux = pkgs.utillinux;
|
||||||
};
|
};
|
||||||
getconf = {
|
getconf = {
|
||||||
linux = if hostPlatform.libc == "glibc" then lib.getBin pkgs.glibc
|
linux = if hostPlatform.libc == "glibc" then pkgs.glibc
|
||||||
else pkgs.netbsd.getconf;
|
else pkgs.netbsd.getconf;
|
||||||
darwin = pkgs.darwin.system_cmds;
|
darwin = pkgs.darwin.system_cmds;
|
||||||
};
|
};
|
||||||
getent = {
|
getent = {
|
||||||
linux = if hostPlatform.libc == "glibc" then lib.getBin pkgs.glibc
|
linux = if hostPlatform.libc == "glibc" then pkgs.glibc
|
||||||
else pkgs.netbsd.getent;
|
else pkgs.netbsd.getent;
|
||||||
darwin = pkgs.netbsd.getent;
|
darwin = pkgs.netbsd.getent;
|
||||||
};
|
};
|
||||||
|
@ -165,10 +168,11 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
makeCompat = name': value: buildEnv {
|
makeCompat = pname: paths:
|
||||||
name = name' + "-compat-${version}";
|
buildEnv {
|
||||||
paths = value;
|
name = "${pname}-${version}";
|
||||||
};
|
inherit paths;
|
||||||
|
};
|
||||||
|
|
||||||
# Compatibility derivations
|
# Compatibility derivations
|
||||||
# Provided for old usage of these commands.
|
# Provided for old usage of these commands.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user