blob: 0cff459bc620bb303c196d37816a618ad899e7b4 (
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
46
47
48
49
50
51
52
53
54
|
{ pkgs ? (import ../../../../.. { }) }:
let
inherit (pkgs) runCommand writeText texlive nix;
inherit (pkgs.lib)
attrValues
concatMap
concatMapStrings
isDerivation
filter
optional
optionalString
sort
strings
;
getFods = drv: optional (isDerivation drv.tex) (drv.tex // { tlType = "run"; })
++ optional (drv ? texdoc) (drv.texdoc // { tlType = "doc"; })
++ optional (drv ? texsource) (drv.texsource // { tlType = "source"; })
++ optional (drv ? tlpkg) (drv.tlpkg // { tlType = "tlpkg"; });
sorted = sort (a: b: a.pname < b.pname) (attrValues texlive.pkgs);
fods = concatMap getFods sorted;
computeHash = fod: runCommand "${fod.pname}-${fod.tlType}-fixed-hash"
{ buildInputs = [ nix ]; inherit fod; }
''echo -n "$(nix-hash --base32 --type sha256 "$fod")" >"$out"'';
hash = fod: fod.outputHash or (builtins.readFile (computeHash fod));
hashes = fods:
concatMapStrings ({ tlType, ... }@p: ''${tlType}="${hash p}";'') fods;
hashLine = { pname, revision, extraRevision ? "", ... }@drv:
let
fods = getFods drv;
# NOTE: the fixed naming scheme must match default.nix
fixedName = "${pname}-${toString revision}${extraRevision}";
in
optionalString (fods != [ ]) ''
${strings.escapeNixIdentifier fixedName}={${hashes fods}};
'';
in
{
# fixedHashesNix uses 'import from derivation' which does not parallelize well
# you should build newHashes first, before evaluating (and building) fixedHashesNix
newHashes = map computeHash (filter (fod: ! fod ? outputHash) fods);
fixedHashesNix = writeText "fixed-hashes.nix"
''
{
${concatMapStrings hashLine sorted}}
'';
}
|