Loading pkgs/build-support/trivial-builders.nix +2 −1 Original line number Diff line number Diff line Loading @@ -489,7 +489,8 @@ rec { let entries' = if (lib.isAttrs entries) then entries else if (lib.isList entries) then lib.listToAttrs (map (x: lib.nameValuePair x.name x.path) entries) # We do this foldl to have last-wins semantics in case of repeated entries else if (lib.isList entries) then lib.foldl (a: b: a // { "${b.name}" = b.path; }) { } entries else throw "linkFarm entries must be either attrs or a list!"; linkCommands = lib.mapAttrsToList (name: path: '' Loading pkgs/build-support/trivial-builders/test/link-farm.nix 0 → 100644 +45 −0 Original line number Diff line number Diff line { linkFarm, hello, writeTextFile, runCommand }: let foo = writeTextFile { name = "foo"; text = "foo"; }; linkFarmFromList = linkFarm "linkFarmFromList" [ { name = "foo"; path = foo; } { name = "hello"; path = hello; } ]; linkFarmWithRepeats = linkFarm "linkFarmWithRepeats" [ { name = "foo"; path = foo; } { name = "hello"; path = hello; } { name = "foo"; path = hello; } ]; linkFarmFromAttrs = linkFarm "linkFarmFromAttrs" { inherit foo hello; }; in runCommand "test-linkFarm" { } '' function assertPathEquals() { local a b; a="$(realpath "$1")" b="$(realpath "$2")" if [ "$a" != "$b" ]; then echo "path mismatch!" echo "a: $1 -> $a" echo "b: $2 -> $b" exit 1 fi } assertPathEquals "${linkFarmFromList}/foo" "${foo}" assertPathEquals "${linkFarmFromList}/hello" "${hello}" assertPathEquals "${linkFarmWithRepeats}/foo" "${hello}" assertPathEquals "${linkFarmWithRepeats}/hello" "${hello}" assertPathEquals "${linkFarmFromAttrs}/foo" "${foo}" assertPathEquals "${linkFarmFromAttrs}/hello" "${hello}" touch $out '' pkgs/test/default.nix +1 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ with pkgs; references = callPackage ../build-support/trivial-builders/test/references.nix {}; overriding = callPackage ../build-support/trivial-builders/test-overriding.nix {}; concat = callPackage ../build-support/trivial-builders/test/concat-test.nix {}; linkFarm = callPackage ../build-support/trivial-builders/test/link-farm.nix {}; }; writers = callPackage ../build-support/writers/test.nix {}; Loading Loading
pkgs/build-support/trivial-builders.nix +2 −1 Original line number Diff line number Diff line Loading @@ -489,7 +489,8 @@ rec { let entries' = if (lib.isAttrs entries) then entries else if (lib.isList entries) then lib.listToAttrs (map (x: lib.nameValuePair x.name x.path) entries) # We do this foldl to have last-wins semantics in case of repeated entries else if (lib.isList entries) then lib.foldl (a: b: a // { "${b.name}" = b.path; }) { } entries else throw "linkFarm entries must be either attrs or a list!"; linkCommands = lib.mapAttrsToList (name: path: '' Loading
pkgs/build-support/trivial-builders/test/link-farm.nix 0 → 100644 +45 −0 Original line number Diff line number Diff line { linkFarm, hello, writeTextFile, runCommand }: let foo = writeTextFile { name = "foo"; text = "foo"; }; linkFarmFromList = linkFarm "linkFarmFromList" [ { name = "foo"; path = foo; } { name = "hello"; path = hello; } ]; linkFarmWithRepeats = linkFarm "linkFarmWithRepeats" [ { name = "foo"; path = foo; } { name = "hello"; path = hello; } { name = "foo"; path = hello; } ]; linkFarmFromAttrs = linkFarm "linkFarmFromAttrs" { inherit foo hello; }; in runCommand "test-linkFarm" { } '' function assertPathEquals() { local a b; a="$(realpath "$1")" b="$(realpath "$2")" if [ "$a" != "$b" ]; then echo "path mismatch!" echo "a: $1 -> $a" echo "b: $2 -> $b" exit 1 fi } assertPathEquals "${linkFarmFromList}/foo" "${foo}" assertPathEquals "${linkFarmFromList}/hello" "${hello}" assertPathEquals "${linkFarmWithRepeats}/foo" "${hello}" assertPathEquals "${linkFarmWithRepeats}/hello" "${hello}" assertPathEquals "${linkFarmFromAttrs}/foo" "${foo}" assertPathEquals "${linkFarmFromAttrs}/hello" "${hello}" touch $out ''
pkgs/test/default.nix +1 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ with pkgs; references = callPackage ../build-support/trivial-builders/test/references.nix {}; overriding = callPackage ../build-support/trivial-builders/test-overriding.nix {}; concat = callPackage ../build-support/trivial-builders/test/concat-test.nix {}; linkFarm = callPackage ../build-support/trivial-builders/test/link-farm.nix {}; }; writers = callPackage ../build-support/writers/test.nix {}; Loading