texlive.combine: move dependencies to attribute tlDeps, resolve them with genericClosure

This commit is contained in:
Vincenzo Mantova
2023-04-02 13:00:52 +01:00
parent 2020863f24
commit 240cc59942
2 changed files with 35 additions and 30 deletions
@@ -10,18 +10,18 @@ let
pkgSet = removeAttrs args [ "pkgFilter" "extraName" "extraVersion" ] // {
# include a fake "core" package
core.pkgs = [
(bin.core.out // { pname = "core"; tlType = "bin"; })
(bin.core.doc // { pname = "core"; tlType = "doc"; })
(bin.core.out // { pname = "core"; version = "0"; tlType = "bin"; })
(bin.core.doc // { pname = "core"; version = "0"; tlType = "doc"; })
];
};
pkgList = rec {
all = lib.filter pkgFilter (combinePkgs (lib.attrValues pkgSet));
splitBin = builtins.partition (p: p.tlType == "bin") all;
bin = mkUniqueOutPaths splitBin.right
bin = splitBin.right
++ lib.optional
(lib.any (p: p.tlType == "run" && p.pname == "pdfcrop") splitBin.wrong)
(lib.getBin ghostscript);
nonbin = mkUniqueOutPaths splitBin.wrong;
nonbin = splitBin.wrong;
# extra interpreters needed for shebangs, based on 2015 schemes "medium" and "tetex"
# (omitted tk needed in pname == "epspdf", bin/epspdftk)
@@ -35,15 +35,13 @@ let
sortedUniqueStrings = list: lib.sort (a: b: a < b) (lib.unique list);
mkUniqueOutPaths = pkgs: lib.unique
(map (p: p.outPath) (builtins.filter lib.isDerivation pkgs));
name = "texlive-${extraName}-${bin.texliveYear}${extraVersion}";
texmf = (buildEnv {
name = "${name}-texmf";
paths = pkgList.nonbin;
# remove fake derivations (without 'outPath') to avoid undesired build dependencies
paths = lib.catAttrs "outPath" pkgList.nonbin;
nativeBuildInputs = [ perl bin.core.out ];
@@ -72,7 +70,9 @@ in (buildEnv {
inherit name;
ignoreCollisions = false;
paths = pkgList.bin ++ [ doc ];
# remove fake derivations (without 'outPath') to avoid undesired build dependencies
paths = lib.catAttrs "outPath" pkgList.bin ++ [ doc ];
pathsToLink = [
"/"
"/bin" # ensure these are writeable directories
+26 -21
View File
@@ -31,10 +31,8 @@ let
# the set of TeX Live packages, collections, and schemes; using upstream naming
tl = let
orig = import ./tlpdb.nix;
removeSelfDep = lib.mapAttrs
(n: p: if p ? deps then p // { deps = lib.filter (dn: n != dn) p.deps; }
else p);
clean = removeSelfDep (orig // {
overridden = orig // {
# overrides of texlive.tlpdb
texlive-msg-translations = orig.texlive-msg-translations // {
@@ -57,11 +55,6 @@ let
deps = orig.collection-plaingeneric.deps ++ [ "xdvi" ];
};
# override cyclic dependency until #167226 is fixed
xecjk = orig.xecjk // {
deps = lib.remove "ctex" orig.xecjk.deps;
};
texdoc = orig.texdoc // {
# build Data.tlpdb.lua (part of the 'tlType == "run"' package)
postUnpack = ''
@@ -80,19 +73,16 @@ let
fi
'';
};
}); # overrides
}; # overrides
linkDeps = lib.mapAttrs (_: attrs: attrs // lib.optionalAttrs (attrs ? deps) {
deps = builtins.map (n: tl.${n}) attrs.deps;
}); # transform [ "dep1" "dep2" ... ] into [ tl."dep1" ... ]
in lib.mapAttrs flatDeps (linkDeps clean);
in lib.mapAttrs mkTLPkg overridden;
# TODO: texlive.infra for web2c config?
flatDeps = pname: attrs:
# create a TeX package: an attribute set { pkgs = [ ... ]; ... } where pkgs is a list of derivations
mkTLPkg = pname: attrs:
let
version = attrs.version or (builtins.toString attrs.revision);
version = attrs.version or (toString attrs.revision);
mkPkgV = tlType: let
pkg = attrs // {
sha512 = attrs.sha512.${tlType};
@@ -110,13 +100,13 @@ let
tlType = "run";
hasFormats = attrs.hasFormats or false;
hasHyphens = attrs.hasHyphens or false;
tlDeps = map (n: tl.${n}) (attrs.deps or []);
}
)]
++ lib.optional (attrs.sha512 ? doc) (mkPkgV "doc")
++ lib.optional (attrs.sha512 ? source) (mkPkgV "source")
++ lib.optional (bin ? ${pname})
( bin.${pname} // { inherit pname; tlType = "bin"; } )
++ combinePkgs (attrs.deps or []);
( bin.${pname} // { tlType = "bin"; } );
};
# for daily snapshots
@@ -172,6 +162,9 @@ let
# metadata for texlive.combine
passthru = {
inherit pname tlType version;
} // lib.optionalAttrs (tlType == "run" && args ? deps) {
tlDeps = map (n: tl.${n}) args.deps;
} // lib.optionalAttrs (tlType == "run") {
hasFormats = args.hasFormats or false;
hasHyphens = args.hasHyphens or false;
};
@@ -190,8 +183,20 @@ let
);
# combine a set of TL packages into a single TL meta-package
combinePkgs = pkgList: lib.concatLists # uniqueness is handled in `combine`
(builtins.map (a: a.pkgs) pkgList);
combinePkgs = pkgList: lib.catAttrs "pkg" (
let
# a TeX package is an attribute set { pkgs = [ ... ]; ... } where pkgs is a list of derivations
# the derivations make up the TeX package and optionally (for backward compatibility) its dependencies
tlPkgToSets = { pkgs, ... }: map ({ pname, tlType, version, outputName ? "", ... }@pkg: {
# outputName required to distinguish among bin.core-big outputs
key = "${pname}.${tlType}-${version}-${outputName}";
inherit pkg;
}) pkgs;
pkgListToSets = lib.concatMap tlPkgToSets; in
builtins.genericClosure {
startSet = pkgListToSets pkgList;
operator = { pkg, ... }: pkgListToSets (pkg.tlDeps or []);
});
in
tl // {