texlive: make packages fixed-output derivations
This reverts a part of the changes made in #40826. Fixed-output derivations save time and space on rebuilds.
This commit is contained in:
parent
d5816c9bcb
commit
738bae4ec2
@ -29,6 +29,7 @@
|
|||||||
{ stdenv, lib, fetchurl, runCommand, writeText, buildEnv
|
{ stdenv, lib, fetchurl, runCommand, writeText, buildEnv
|
||||||
, callPackage, ghostscriptX, harfbuzz, poppler_min
|
, callPackage, ghostscriptX, harfbuzz, poppler_min
|
||||||
, makeWrapper, python, ruby, perl
|
, makeWrapper, python, ruby, perl
|
||||||
|
, useFixedHashes ? true
|
||||||
, recurseIntoAttrs
|
, recurseIntoAttrs
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
@ -41,6 +42,10 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# map: name -> fixed-output hash
|
||||||
|
# sha1 in base32 was chosen as a compromise between security and length
|
||||||
|
fixedHashes = lib.optionalAttrs useFixedHashes (import ./fixedHashes.nix);
|
||||||
|
|
||||||
# function for creating a working environment from a set of TL packages
|
# function for creating a working environment from a set of TL packages
|
||||||
combine = import ./combine.nix {
|
combine = import ./combine.nix {
|
||||||
inherit bin combinePkgs buildEnv fastUnique lib makeWrapper writeText
|
inherit bin combinePkgs buildEnv fastUnique lib makeWrapper writeText
|
||||||
@ -116,6 +121,7 @@ let
|
|||||||
# the basename used by upstream (without ".tar.xz" suffix)
|
# the basename used by upstream (without ".tar.xz" suffix)
|
||||||
urlName = pname + lib.optionalString (tlType != "run") ".${tlType}";
|
urlName = pname + lib.optionalString (tlType != "run") ".${tlType}";
|
||||||
tlName = urlName + "-${version}";
|
tlName = urlName + "-${version}";
|
||||||
|
fixedHash = fixedHashes.${tlName} or null; # be graceful about missing hashes
|
||||||
|
|
||||||
urls = args.urls or (if args ? url then [ args.url ] else
|
urls = args.urls or (if args ? url then [ args.url ] else
|
||||||
map (up: "${up}/${urlName}.tar.xz") urlPrefixes
|
map (up: "${up}/${urlName}.tar.xz") urlPrefixes
|
||||||
@ -155,11 +161,30 @@ let
|
|||||||
-C "$out" --anchored --exclude=tlpkg --keep-old-files
|
-C "$out" --anchored --exclude=tlpkg --keep-old-files
|
||||||
'' + postUnpack;
|
'' + postUnpack;
|
||||||
|
|
||||||
in runCommand "texlive-${tlName}" {
|
in if sha512 == "" then
|
||||||
# lots of derivations, not meant to be cached
|
# hash stripped from pkgs.nix to save space -> fetch&unpack in a single step
|
||||||
|
fetchurl {
|
||||||
|
inherit urls;
|
||||||
|
sha1 = if fixedHash == null then throw "TeX Live package ${tlName} is missing hash!"
|
||||||
|
else fixedHash;
|
||||||
|
name = tlName;
|
||||||
|
recursiveHash = true;
|
||||||
|
downloadToTemp = true;
|
||||||
|
postFetch = ''mkdir "$out";'' + unpackCmd "$downloadedFile";
|
||||||
|
# TODO: perhaps override preferHashedMirrors and allowSubstitutes
|
||||||
|
}
|
||||||
|
// passthru
|
||||||
|
|
||||||
|
else runCommand "texlive-${tlName}"
|
||||||
|
( { # lots of derivations, not meant to be cached
|
||||||
preferLocalBuild = true; allowSubstitutes = false;
|
preferLocalBuild = true; allowSubstitutes = false;
|
||||||
inherit passthru;
|
inherit passthru;
|
||||||
|
} // lib.optionalAttrs (fixedHash != null) {
|
||||||
|
outputHash = fixedHash;
|
||||||
|
outputHashAlgo = "sha1";
|
||||||
|
outputHashMode = "recursive";
|
||||||
}
|
}
|
||||||
|
)
|
||||||
( ''
|
( ''
|
||||||
mkdir "$out"
|
mkdir "$out"
|
||||||
'' + unpackCmd "'${src}'"
|
'' + unpackCmd "'${src}'"
|
||||||
|
10
pkgs/tools/typesetting/tex/texlive/fixHashes.sh
Executable file
10
pkgs/tools/typesetting/tex/texlive/fixHashes.sh
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo "{"
|
||||||
|
grep -v -F '.bin-' | while read path; do
|
||||||
|
hash=`nix-hash --type sha1 --base32 "$path"`
|
||||||
|
echo -n "$path" | sed -E 's/[^-]*-texlive-(.*)/"\1"/'
|
||||||
|
echo "=\"$hash\";"
|
||||||
|
done
|
||||||
|
echo "}"
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user