Merge pull request #37953 from obsidiansystems/unixtools

unixtools: Utilize meta.platforms
This commit is contained in:
Matthew Justin Bauer 2018-03-27 21:21:52 -05:00 committed by GitHub
commit 2162eb4bed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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 {