2024-06-30 08:16:52 +00:00
|
|
|
{
|
|
|
|
pkgs ? (import ../../../../.. { }),
|
|
|
|
}:
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
let
|
2024-06-30 08:16:52 +00:00
|
|
|
inherit (pkgs)
|
|
|
|
runCommand
|
|
|
|
writeText
|
|
|
|
texlive
|
|
|
|
nix
|
|
|
|
;
|
2024-05-02 00:46:19 +00:00
|
|
|
inherit (pkgs.lib)
|
|
|
|
attrValues
|
|
|
|
concatMap
|
|
|
|
concatMapStrings
|
|
|
|
isDerivation
|
|
|
|
filter
|
|
|
|
optional
|
|
|
|
optionalString
|
|
|
|
sort
|
|
|
|
strings
|
|
|
|
;
|
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
getFods =
|
|
|
|
drv:
|
|
|
|
optional (isDerivation drv.tex) (drv.tex // { tlType = "run"; })
|
2024-05-02 00:46:19 +00:00
|
|
|
++ 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;
|
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
computeHash =
|
|
|
|
fod:
|
|
|
|
runCommand "${fod.pname}-${fod.tlType}-fixed-hash" {
|
|
|
|
buildInputs = [ nix ];
|
|
|
|
inherit fod;
|
|
|
|
} ''echo -n "$(nix-hash --base32 --type sha256 "$fod")" >"$out"'';
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
hash = fod: fod.outputHash or (builtins.readFile (computeHash fod));
|
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
hashes = fods: concatMapStrings ({ tlType, ... }@p: ''${tlType}="${hash p}";'') fods;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
hashLine =
|
|
|
|
{
|
|
|
|
pname,
|
|
|
|
revision,
|
|
|
|
extraRevision ? "",
|
|
|
|
...
|
|
|
|
}@drv:
|
2024-05-02 00:46:19 +00:00
|
|
|
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
|
2024-06-30 08:16:52 +00:00
|
|
|
newHashes = map computeHash (filter (fod: !fod ? outputHash) fods);
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:16:52 +00:00
|
|
|
fixedHashesNix = writeText "fixed-hashes.nix" ''
|
|
|
|
{
|
|
|
|
${concatMapStrings hashLine sorted}}
|
|
|
|
'';
|
2024-05-02 00:46:19 +00:00
|
|
|
}
|