From 52f4be2c1fd6d430437f917ec886cb12798efdb4 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 27 Mar 2018 20:26:10 -0400 Subject: [PATCH] unixtools: Utilize meta.platforms --- pkgs/top-level/unix-tools.nix | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/pkgs/top-level/unix-tools.nix b/pkgs/top-level/unix-tools.nix index 2e2cc3cea880..0d6e8d1c6c2d 100644 --- a/pkgs/top-level/unix-tools.nix +++ b/pkgs/top-level/unix-tools.nix @@ -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 {