diff options
author | Alyssa Ross <hi@alyssa.is> | 2023-08-23 10:09:14 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2023-08-26 09:07:03 +0000 |
commit | 63dabcc77ef9a56655e1ca2ab2e25e6163a72c1f (patch) | |
tree | d58934cb48f9c953b19a0d0d5cffc0d0c5561471 /nixpkgs/pkgs/tools/typesetting/tex/texlive/generate-fixed-hashes.nix | |
parent | c4eef3dacb2a3d359561f30917d9e3cc4e041be9 (diff) | |
parent | 91a22f76cd1716f9d0149e8a5c68424bb691de15 (diff) | |
download | nixlib-63dabcc77ef9a56655e1ca2ab2e25e6163a72c1f.tar nixlib-63dabcc77ef9a56655e1ca2ab2e25e6163a72c1f.tar.gz nixlib-63dabcc77ef9a56655e1ca2ab2e25e6163a72c1f.tar.bz2 nixlib-63dabcc77ef9a56655e1ca2ab2e25e6163a72c1f.tar.lz nixlib-63dabcc77ef9a56655e1ca2ab2e25e6163a72c1f.tar.xz nixlib-63dabcc77ef9a56655e1ca2ab2e25e6163a72c1f.tar.zst nixlib-63dabcc77ef9a56655e1ca2ab2e25e6163a72c1f.zip |
Merge branch 'nixos-unstable' of https://github.com/NixOS/nixpkgs
Conflicts: nixpkgs/pkgs/build-support/go/module.nix nixpkgs/pkgs/development/python-modules/django-mailman3/default.nix
Diffstat (limited to 'nixpkgs/pkgs/tools/typesetting/tex/texlive/generate-fixed-hashes.nix')
-rw-r--r-- | nixpkgs/pkgs/tools/typesetting/tex/texlive/generate-fixed-hashes.nix | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/nixpkgs/pkgs/tools/typesetting/tex/texlive/generate-fixed-hashes.nix b/nixpkgs/pkgs/tools/typesetting/tex/texlive/generate-fixed-hashes.nix index 738fef022010..dedb877448a6 100644 --- a/nixpkgs/pkgs/tools/typesetting/tex/texlive/generate-fixed-hashes.nix +++ b/nixpkgs/pkgs/tools/typesetting/tex/texlive/generate-fixed-hashes.nix @@ -1,32 +1,33 @@ with import ../../../../.. { }; with lib; let - # NOTE: the fixed naming scheme must match default.nix - # name for the URL - mkURLName = { pname, tlType, ... }: pname + lib.optionalString (tlType != "run" && tlType != "tlpkg") ".${tlType}"; - # name + revision for the fixed output hashes - mkFixedName = { tlType, revision, extraRevision ? "", ... }@attrs: mkURLName attrs + (lib.optionalString (tlType == "tlpkg") ".tlpkg") + ".r${toString revision}${extraRevision}"; - - uniqueByName = fods: catAttrs "fod" (genericClosure { - startSet = map (fod: { key = fod.name; inherit fod; }) fods; - operator = _: [ ]; - }); + isFod = p: p.tlType != "bin" && isDerivation p; # ugly hack to extract combine from collection-latexextra, since it is masked by texlive.combine - combine = lib.findFirst (p: (lib.head p.pkgs).pname == "combine") { pkgs = []; } (lib.head texlive.collection-latexextra.pkgs).tlDeps; - all = concatLists (map (p: p.pkgs or []) (attrValues (removeAttrs texlive [ "bin" "combine" "combined" "tlpdb" ]))) ++ combine.pkgs; - - # fixed hashes only for run, doc, source, tlpkg types - fods = sort (a: b: a.name < b.name) (uniqueByName (filter (p: isDerivation p && p.tlType != "bin") all)); + combine = lib.findFirst (p: (lib.head p.pkgs).pname == "combine") { pkgs = [ ]; } (lib.head texlive.collection-latexextra.pkgs).tlDeps; + all = filter (p: p ? pkgs) (attrValues (removeAttrs texlive [ "bin" "combine" "combined" "tlpdb" ])) ++ [ combine ]; + sorted = sort (a: b: (head a.pkgs).pname < (head b.pkgs).pname) all; + fods = filter isFod (concatMap (p: p.pkgs or [ ]) all); - computeHash = fod: runCommand "${fod.name}-fixed-hash" + 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)); - hashLine = fod: '' - "${mkFixedName fod}"="${hash fod}"; - ''; + + hashes = { pkgs }: + concatMapStrings ({ tlType, ... }@p: lib.optionalString (isFod p) (''${tlType}="${hash p}";'')) pkgs; + + hashLine = { pkgs }@pkg: + let + fods = lib.filter isFod pkgs; + first = lib.head fods; + # NOTE: the fixed naming scheme must match default.nix + fixedName = with first; "${pname}-${toString revision}${first.extraRevision or ""}"; + in + lib.optionalString (fods != [ ]) '' + ${strings.escapeNixIdentifier fixedName}={${hashes pkg}}; + ''; in { # fixedHashesNix uses 'import from derivation' which does not parallelize well @@ -34,8 +35,8 @@ in newHashes = map computeHash (filter (fod: ! fod ? outputHash) fods); fixedHashesNix = writeText "fixed-hashes.nix" - '' - { - ${lib.concatMapStrings hashLine fods}} - ''; + '' + { + ${lib.concatMapStrings hashLine sorted}} + ''; } |