diff options
author | Uli Baum <xeji@cat3.de> | 2018-08-27 14:04:43 +0200 |
---|---|---|
committer | Uli Baum <xeji@cat3.de> | 2018-08-29 11:03:44 +0200 |
commit | 738bae4ec2a73c16fa8d4f76b0a41474937a366c (patch) | |
tree | 13004e2756cc0ec7f4eb1ac608c76920a1d63f1b /pkgs/tools/typesetting | |
parent | d5816c9bcb170281ba2b13acb0f19edf4b3cd1c4 (diff) | |
download | nixlib-738bae4ec2a73c16fa8d4f76b0a41474937a366c.tar nixlib-738bae4ec2a73c16fa8d4f76b0a41474937a366c.tar.gz nixlib-738bae4ec2a73c16fa8d4f76b0a41474937a366c.tar.bz2 nixlib-738bae4ec2a73c16fa8d4f76b0a41474937a366c.tar.lz nixlib-738bae4ec2a73c16fa8d4f76b0a41474937a366c.tar.xz nixlib-738bae4ec2a73c16fa8d4f76b0a41474937a366c.tar.zst nixlib-738bae4ec2a73c16fa8d4f76b0a41474937a366c.zip |
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.
Diffstat (limited to 'pkgs/tools/typesetting')
-rw-r--r-- | pkgs/tools/typesetting/tex/texlive/default.nix | 35 | ||||
-rwxr-xr-x | pkgs/tools/typesetting/tex/texlive/fixHashes.sh | 10 |
2 files changed, 40 insertions, 5 deletions
diff --git a/pkgs/tools/typesetting/tex/texlive/default.nix b/pkgs/tools/typesetting/tex/texlive/default.nix index e4799e39c434..c10b9c992968 100644 --- a/pkgs/tools/typesetting/tex/texlive/default.nix +++ b/pkgs/tools/typesetting/tex/texlive/default.nix @@ -29,6 +29,7 @@ { stdenv, lib, fetchurl, runCommand, writeText, buildEnv , callPackage, ghostscriptX, harfbuzz, poppler_min , makeWrapper, python, ruby, perl +, useFixedHashes ? true , recurseIntoAttrs }: 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 combine = import ./combine.nix { inherit bin combinePkgs buildEnv fastUnique lib makeWrapper writeText @@ -116,6 +121,7 @@ let # the basename used by upstream (without ".tar.xz" suffix) urlName = pname + lib.optionalString (tlType != "run") ".${tlType}"; tlName = urlName + "-${version}"; + fixedHash = fixedHashes.${tlName} or null; # be graceful about missing hashes urls = args.urls or (if args ? url then [ args.url ] else map (up: "${up}/${urlName}.tar.xz") urlPrefixes @@ -155,11 +161,30 @@ let -C "$out" --anchored --exclude=tlpkg --keep-old-files '' + postUnpack; - in runCommand "texlive-${tlName}" { - # lots of derivations, not meant to be cached - preferLocalBuild = true; allowSubstitutes = false; - inherit passthru; - } + in if sha512 == "" then + # 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; + inherit passthru; + } // lib.optionalAttrs (fixedHash != null) { + outputHash = fixedHash; + outputHashAlgo = "sha1"; + outputHashMode = "recursive"; + } + ) ( '' mkdir "$out" '' + unpackCmd "'${src}'" diff --git a/pkgs/tools/typesetting/tex/texlive/fixHashes.sh b/pkgs/tools/typesetting/tex/texlive/fixHashes.sh new file mode 100755 index 000000000000..439660682e2e --- /dev/null +++ b/pkgs/tools/typesetting/tex/texlive/fixHashes.sh @@ -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 "}" + |