2024-06-30 08:16:52 +00:00
|
|
|
{
|
|
|
|
linkFarm,
|
|
|
|
hello,
|
|
|
|
writeTextFile,
|
|
|
|
runCommand,
|
|
|
|
}:
|
2024-05-02 00:46:19 +00:00
|
|
|
let
|
|
|
|
foo = writeTextFile {
|
|
|
|
name = "foo";
|
|
|
|
text = "foo";
|
|
|
|
};
|
|
|
|
|
|
|
|
linkFarmFromList = linkFarm "linkFarmFromList" [
|
2024-06-30 08:16:52 +00:00
|
|
|
{
|
|
|
|
name = "foo";
|
|
|
|
path = foo;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "hello";
|
|
|
|
path = hello;
|
|
|
|
}
|
2024-05-02 00:46:19 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
linkFarmWithRepeats = linkFarm "linkFarmWithRepeats" [
|
2024-06-30 08:16:52 +00:00
|
|
|
{
|
|
|
|
name = "foo";
|
|
|
|
path = foo;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "hello";
|
|
|
|
path = hello;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "foo";
|
|
|
|
path = hello;
|
|
|
|
}
|
2024-05-02 00:46:19 +00:00
|
|
|
];
|
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
linkFarmFromAttrs = linkFarm "linkFarmFromAttrs" { inherit foo hello; };
|
2024-05-02 00:46:19 +00:00
|
|
|
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
|
|
|
|
''
|