3
0
Fork 0
forked from mirrors/nixpkgs

unixtools: Utilize meta.platforms

This commit is contained in:
John Ericson 2018-03-27 20:26:10 -04:00
parent 49455d7bae
commit 52f4be2c1f

View file

@ -12,19 +12,20 @@
let
singleBinary = cmd: providers:
if builtins.hasAttr hostPlatform.parsed.kernel.name providers then
runCommand cmd {} ''
mkdir -p $out/bin
singleBinary = cmd: providers: let
provider = "${providers.${hostPlatform.parsed.kernel.name} or "missing-package"}/bin/${cmd}";
in runCommand cmd {
meta.platforms = map (n: { kernel.name = n; }) (pkgs.lib.attrNames providers);
} ''
mkdir -p $out/bin
if ! [ -x "${providers.${hostPlatform.parsed.kernel.name}}/bin/${cmd}" ]; then
echo "Cannot find command ${cmd}"
exit 1
fi
if ! [ -x "${provider}" ]; 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}";
ln -s "${provider}" "$out/bin/${cmd}"
'';
in rec {