texlive: assert that all fixed hashes are present

This commit is contained in:
Vincenzo Mantova 2023-06-11 19:37:37 +01:00
parent 3e210b282f
commit 5ef2470f15
2 changed files with 16 additions and 7 deletions

View File

@ -5,7 +5,7 @@
, perl, perlPackages, python3Packages, pkg-config
, libpaper, graphite2, zziplib, harfbuzz, potrace, gmp, mpfr
, brotli, cairo, pixman, xorg, clisp, biber, woff2, xxHash
, makeWrapper, shortenPerlShebang
, makeWrapper, shortenPerlShebang, useFixedHashes
}:
# Useful resource covering build options:
@ -17,6 +17,10 @@ let
year = toString ((import ./tlpdb.nix)."00texlive.config").year;
version = year; # keep names simple for now
# detect and stop redundant rebuilds that may occur when building new fixed hashes
assertFixedHash = name: src:
if ! useFixedHashes || src ? outputHash then src else throw "The TeX Live package '${src.pname}' must have a fixed hash before building '${name}'.";
common = {
src = fetchurl {
urls = [
@ -369,7 +373,7 @@ latexindent = perlPackages.buildPerlPackage rec {
pname = "latexindent";
inherit (src) version;
src = lib.head (builtins.filter (p: p.tlType == "run") texlive.latexindent.pkgs);
src = assertFixedHash pname (lib.head (builtins.filter (p: p.tlType == "run") texlive.latexindent.pkgs));
outputs = [ "out" ];
@ -401,7 +405,7 @@ pygmentex = python3Packages.buildPythonApplication rec {
inherit (src) version;
format = "other";
src = lib.head (builtins.filter (p: p.tlType == "run") texlive.pygmentex.pkgs);
src = assertFixedHash pname (lib.head (builtins.filter (p: p.tlType == "run") texlive.pygmentex.pkgs));
propagatedBuildInputs = with python3Packages; [ pygments chardet ];
@ -437,7 +441,7 @@ pygmentex = python3Packages.buildPythonApplication rec {
texlinks = stdenv.mkDerivation rec {
name = "texlinks";
src = lib.head (builtins.filter (p: p.tlType == "run") texlive.texlive-scripts-extra.pkgs);
src = assertFixedHash name (lib.head (builtins.filter (p: p.tlType == "run") texlive.texlive-scripts-extra.pkgs));
dontBuild = true;
doCheck = false;

View File

@ -16,6 +16,7 @@ let
harfbuzz = harfbuzz.override {
withIcu = true; withGraphite2 = true;
};
inherit useFixedHashes;
};
# function for creating a working environment from a set of TL packages
@ -227,9 +228,13 @@ let
operator = { pkg, ... }: pkgListToSets (pkg.tlDeps or []);
});
assertions =
lib.assertMsg (tlpdbVersion.year == version.texliveYear) "TeX Live year in texlive does not match tlpdb.nix, refusing to evaluate" &&
lib.assertMsg (tlpdbVersion.frozen == version.final) "TeX Live final status in texlive does not match tlpdb.nix, refusing to evaluate";
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));
in
tl // {