From 4e49e4928d44ce1ffc9a880ec035d1441a1b7650 Mon Sep 17 00:00:00 2001 From: Vincenzo Mantova <1962985+xworld21@users.noreply.github.com> Date: Sat, 26 Aug 2023 22:12:41 +0100 Subject: [PATCH] tests.texlive.fixedHashes: init (#248746) The assertion that all TeX Live packages have a fixed hash is time consuming and should only be checked when running tests. --- pkgs/test/texlive/default.nix | 21 +++++++++++++++++++ .../tools/typesetting/tex/texlive/default.nix | 6 +----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/pkgs/test/texlive/default.nix b/pkgs/test/texlive/default.nix index 1d339c1ddd0b..50f274f6f7e0 100644 --- a/pkgs/test/texlive/default.nix +++ b/pkgs/test/texlive/default.nix @@ -511,4 +511,25 @@ echo "$errorText" false ''); + + # verify that all fixed hashes are present + # this is effectively an eval-time assertion, converted into a derivation for + # ease of testing + fixedHashes = with lib; let + combine = findFirst (p: (head p.pkgs).pname == "combine") { pkgs = []; } (head texlive.collection-latexextra.pkgs).tlDeps; + all = concatLists (map (p: p.pkgs or []) (attrValues (removeAttrs texlive [ "bin" "combine" "combined" "tlpdb" ]))) ++ combine.pkgs; + fods = filter (p: isDerivation p && p.tlType != "bin") all; + errorText = concatMapStrings (p: optionalString (! p ? outputHash) "${p.pname + optionalString (p.tlType != "run") ("." + p.tlType)} does not have a fixed output hash\n") fods; + in runCommand "texlive-test-fixed-hashes" { + inherit errorText; + passAsFile = [ "errorText" ]; + } '' + if [[ -s "$errorTextPath" ]] ; then + cat "$errorTextPath" + echo Failed: some TeX Live packages do not have fixed output hashes. Please read UPGRADING.md for how to generate a new fixed-hashes.nix. + exit 1 + else + touch "$out" + fi + ''; } diff --git a/pkgs/tools/typesetting/tex/texlive/default.nix b/pkgs/tools/typesetting/tex/texlive/default.nix index 9839d764adf4..b382dc258e8c 100644 --- a/pkgs/tools/typesetting/tex/texlive/default.nix +++ b/pkgs/tools/typesetting/tex/texlive/default.nix @@ -496,11 +496,7 @@ let assertions = with lib; assertMsg (tlpdbVersion.year == version.texliveYear) "TeX Live year in texlive does not match tlpdb.nix, refusing to evaluate" && - assertMsg (tlpdbVersion.frozen == version.final) "TeX Live final status in texlive does not match tlpdb.nix, refusing to evaluate" && - (!useFixedHashes || - (let all = concatLists (catAttrs "pkgs" (attrValues tl)); - fods = filter (p: isDerivation p && p.tlType != "bin") all; - in builtins.all (p: assertMsg (p ? outputHash) "The TeX Live package '${p.pname + lib.optionalString (p.tlType != "run") ("." + p.tlType)}' does not have a fixed output hash. Please read UPGRADING.md on how to build a new 'fixed-hashes.nix'.") fods)); + assertMsg (tlpdbVersion.frozen == version.final) "TeX Live final status in texlive does not match tlpdb.nix, refusing to evaluate"; in tl // {