blob: 1ebfc707632f3178918eda4e2ef7f0d6d2d0d646 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
{ 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
''
|