@@ -21,7 +21,8 @@ let
2121 # map: name -> fixed-output hash
2222 # sha1 in base32 was chosen as a compromise between security and length
2323 # warning: the following generator command takes lots of resources
24− # nix-build ../../../../.. -Q -A texlive.scheme-full.pkgs | ./fixHashes.sh > ./fixedHashes.nix
24+ # nix-build ../../../../.. -Q -A texlive.scheme-full.pkgs | ./fixHashes.sh > ./fixedHashes-new.nix
25+ # mv ./fixedHashes{-new,}.nix
2526 fixedHashes = lib.optionalAttrs useFixedHashes (import ./fixedHashes.nix);
2627
2728 # function for creating a working environment from a set of TL packages
@@ -82,10 +83,7 @@ let
8283 sha512 = attrs.sha512.${tlType};
8384 inherit pname tlType version;
8485 };
85− in mkPkgs {
86− inherit (pkg) pname tlType version;
87− pkgList = [ pkg ];
88− };
86+ in mkPkg pkg;
8987 in {
9088 # TL pkg contains lists of packages: runtime files, docs, sources, binaries
9189 pkgs =
@@ -101,50 +99,49 @@ let
10199 ++ combinePkgs (attrs.deps or {});
102100 };
103101
104− # the basename used by upstream (without ".tar.xz" suffix)
105− mkUrlName = { pname, tlType, ... }:
106− pname + lib.optionalString (tlType != "run") ".${tlType}";
102+ # create a derivation that contains an unpacked upstream TL package
103+ mkPkg = { pname, tlType, version, sha512, postUnpack ? "", stripPrefix ? 1, ... }@args:
104+ let
105+ # the basename used by upstream (without ".tar.xz" suffix)
106+ urlName = pname + lib.optionalString (tlType != "run") ".${tlType}";
107+ tlName = urlName + "-${version}";
108+ fixedHash = fixedHashes.${tlName} or null; # be graceful about missing hashes
107109
108− # command to unpack a single TL package
109− unpackPkg =
110− { # url ? null, urlPrefix ? null
111− sha512, pname, tlType, postUnpack ? "", stripPrefix ? 1, ...
112− }@args: let
113− url = args.url or "${urlPrefix}/${mkUrlName args}.tar.xz";
110+ url = args.url or "${urlPrefix}/${urlName}.tar.xz";
114111 urlPrefix = args.urlPrefix or
112+ http://lipa.ms.mff.cuni.cz/~cunav5am/nix/texlive-2016;
115113 # XXX XXX XXX FIXME: mirror the snapshot XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX
116114 # ("${mirror}/pub/tex/historic/systems/texlive/${bin.texliveYear}/tlnet-final/archive");
117− # http://mirror.ctan.org/tex-archive/systems/texlive/tlnet/archive;
118− http://lipa.ms.mff.cuni.cz/~cunav5am/nix/texlive-2016;
119− # beware: standard mirrors http://mirror.ctan.org/ don't have releases
120− #mirror = "http://ftp.math.utah.edu"; # ftp://tug.ctan.org no longer works, although same IP
121− in
122− rec {
123− src = fetchurl { inherit url sha512; };
124− unpackCmd = ''
125− tar -xf '${src}' \
126− '--strip-components=${toString stripPrefix}' \
127− -C "$out" --anchored --exclude=tlpkg --keep-old-files
128− '' + postUnpack;
129− };
130−
131− # create a derivation that contains unpacked upstream TL packages
132− mkPkgs = { pname, tlType, version, pkgList }@args:
133− /* TODOs:
134− - "historic" isn't mirrored; posted a question at #287
135− - maybe cache (some) collections? (they don't overlap)
136− */
137− let
138− tlName = "${mkUrlName args}-${version}";
139− fixedHash = fixedHashes.${tlName} or null; # be graceful about missing hashes
140− pkgs = map unpackPkg (fastUnique (a: b: a.sha512 < b.sha512) pkgList);
141− in runCommand "texlive-${tlName}"
115+ #mirror = "http://ftp.math.utah.edu";
116+ src = fetchurl { inherit url sha512; };
117+
118+ passthru = {
119+ inherit pname tlType version;
120+ } // lib.optionalAttrs (sha512 != "") { inherit src; };
121+ unpackCmd = file: ''
122+ tar -xf ${file} \
123+ '--strip-components=${toString stripPrefix}' \
124+ -C "$out" --anchored --exclude=tlpkg --keep-old-files
125+ '' + postUnpack;
126+
127+ in if sha512 == "" then
128+ # hash stripped from pkgs.nix to save space -> fetch&unpack in a single step
129+ fetchurl {
130+ inherit url;
131+ sha1 = if fixedHash == null then throw "TeX Live package ${tlName} is missing hash!"
132+ else fixedHash;
133+ name = tlName;
134+ recursiveHash = true;
135+ downloadToTemp = true;
136+ postFetch = ''mkdir "$out";'' + unpackCmd "$downloadedFile";
137+ # TODO: perhaps override preferHashedMirrors and allowSubstitutes
138+ }
139+ // passthru
140+
141+ else runCommand "texlive-${tlName}"
142142 ( { # lots of derivations, not meant to be cached
143143 preferLocalBuild = true; allowSubstitutes = false;
144− passthru = {
145− inherit pname tlType version;
146− srcs = map (pkg: pkg.src) pkgs;
147− };
144+ inherit passthru;
148145 } // lib.optionalAttrs (fixedHash != null) {
149146 outputHash = fixedHash;
150147 outputHashAlgo = "sha1";
@@ -153,7 +150,7 @@ let
153150 )
154151 ( ''
155152 mkdir "$out"
156− '' + lib.concatMapStrings (pkg: pkg.unpackCmd) pkgs
153+ '' + unpackCmd "'${src}'"
157154 );
158155
159156 # combine a set of TL packages into a single TL meta-package