-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
77 lines (70 loc) · 2.12 KB
/
default.nix
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{
pkgs ? import <nixpkgs> {},
cacheBreaker ? null,
usePathSource ? true,
useStringifiedPath ? true,
useFilteredPath ? true,
useCleanSource ? true,
useLinkFarm ? true,
...
}:
let
lib = pkgs.lib;
modeFlags = {
inherit usePathSource useStringifiedPath useFilteredPath useLinkFarm;
};
cacheBreakerCalc = if builtins.isNull cacheBreaker
then (builtins.substring 0 5
(builtins.hashString "sha256"
(builtins.toJSON modeFlags)))
else cacheBreaker;
subdirSource = if usePathSource then (import (builtins.path { name = "subdir-source-nonrepro"; path = ./subdir.d; })) else (import ./subdir.d);
subdir = subdirSource {
inherit (pkgs) stdenv coreutils;
version = cacheBreakerCalc;
};
output = lib.trivial.pipe subdir (
# Does "${stringification}" of derivation handles change behaviour?
(lib.optional useStringifiedPath (prev: if useStringifiedPath then "${prev}" else prev))
# Does builtin.path filtration change behaviour?
++ (lib.optional useFilteredPath (prev: builtins.path {
path = prev;
name = "subdir-filtered";
filter = path: type: true;
}))
# Does lib.sources.cleanSourcefiltration change behaviour?
++ (lib.optional useCleanSource lib.sources.cleanSource)
# Does builtin.path pkgs.linkFarm change behaviour?
++ (lib.optional useLinkFarm (prev: pkgs.linkFarm "linkfarm-combined-dir" [
{
name = "hello.txt";
path = "${prev}/hello.txt";
}
{
name = "world.txt";
path = "${prev}/world.txt";
}
{
name = "space.txt";
path = "${pkgs.emptyFile}";
}
]
))
);
# Build a derivation with the content using runCommand to copy it over
resultDerivation =
((pkgs.runCommand
"lst-repro"
{ version = cacheBreakerCalc; }
''
set -e
ls "${output}"
mkdir -p $out
cat "${output}/hello.txt" "${output}/world.txt" > "$out/helloworld.txt"
'')
.overrideAttrs(prev: {
passthru.modeFlags = modeFlags;
inherit cacheBreakerCalc;
})
);
in resultDerivation