diff --git a/pkgs/test/texlive/default.nix b/pkgs/test/texlive/default.nix index ae0e913a760..cb004dc3c97 100644 --- a/pkgs/test/texlive/default.nix +++ b/pkgs/test/texlive/default.nix @@ -321,4 +321,54 @@ echo "tested $binCount binCount: $ignoredCount ignored, $brokenCount broken, $failedCount failed" [[ $failedCount = 0 ]] ''; + + # verify that the precomputed licensing information in default.nix + # does indeed match the metadata of the individual packages. + # + # This is part of the test suite (and not the normal evaluation) to save + # time for "normal" evaluations. To be more in line with the other tests, this + # also builds a derivation, even though it is essentially an eval-time assertion. + licenses = + let + concatLicenses = builtins.foldl' (acc: el: if builtins.elem el acc then acc else acc ++ [ el ]); + # converts a license to its attribute name in lib.licenses + licenseToAttrName = license: + builtins.head (builtins.attrNames + (lib.filterAttrs (n: v: license == v) lib.licenses)); + lt = (a: b: a < b); + + savedLicenses = scheme: scheme.meta.license; + savedLicensesAttrNames = scheme: map licenseToAttrName (savedLicenses scheme); + + correctLicenses = scheme: builtins.foldl' + (acc: pkg: concatLicenses acc (lib.toList (pkg.meta.license or []))) + [] + scheme.passthru.packages; + correctLicensesAttrNames = scheme: + lib.sort lt + (map licenseToAttrName (correctLicenses scheme)); + + hasLicenseMismatch = scheme: + (lib.isDerivation scheme) && + (savedLicensesAttrNames scheme) != (correctLicensesAttrNames scheme); + incorrectSchemes = lib.filterAttrs + (n: hasLicenseMismatch) + texlive.combined; + prettyPrint = name: scheme: + '' + license info for ${name} is incorrect! Note that order is enforced. + saved: [ ${lib.concatStringsSep " " (savedLicensesAttrNames scheme)} ] + correct: [ ${lib.concatStringsSep " " (correctLicensesAttrNames scheme)} ] + ''; + errorText = lib.concatStringsSep "\n\n" (lib.mapAttrsToList prettyPrint incorrectSchemes); + in + runCommand "texlive-test-license" { + inherit errorText; + } + (if (incorrectSchemes == {}) + then "echo everything is fine! > $out" + else '' + echo "$errorText" + false + ''); } diff --git a/pkgs/tools/typesetting/tex/texlive/UPGRADING.md b/pkgs/tools/typesetting/tex/texlive/UPGRADING.md index 12416dee8ce..c9d4a81a2c3 100644 --- a/pkgs/tools/typesetting/tex/texlive/UPGRADING.md +++ b/pkgs/tools/typesetting/tex/texlive/UPGRADING.md @@ -72,6 +72,23 @@ CTAN and the various mirrors) and that the build recipe continues to produce the same output. Should those assumptions not hold, remove the previous fixed hashes for the relevant package, or for all packages. +### Updating the licensing information + +The license of each package in texlive is automatically extracted from texlive's +texlive.tlpdb into tlpdb.nix. The combined licenses of the schemes is stored +separately in `default.nix` and must be kept in sync with the licenses of the +actual contents of these schemes. Whether this is the case can be verified with the +`pkgs.tests.texlive.licenses` test. In case of a mismatch, copy the “correct” +license lists reported by the test into `default.nix`. + +### Running the testsuite + +There are a some other useful tests that haven't been mentioned before. Build them with +``` +nix-build ../../../../.. -A tests.texlive --no-out-link +``` + + ### Commit changes Commit the updated `tlpdb.nix` and `fixed-hashes.nix` to the repository with diff --git a/pkgs/tools/typesetting/tex/texlive/default.nix b/pkgs/tools/typesetting/tex/texlive/default.nix index 6ed1ba7e794..f5696eba4f9 100644 --- a/pkgs/tools/typesetting/tex/texlive/default.nix +++ b/pkgs/tools/typesetting/tex/texlive/default.nix @@ -43,6 +43,7 @@ let # it seems to need it to transform fonts xdvi.deps = (orig.xdvi.deps or []) ++ [ "metafont" ]; + # TODO: remove when updating to texlive-2023, metadata has been corrected in the TeX catalogue # tlpdb lists license as "unknown", but the README says lppl13: http://mirrors.ctan.org/language/arabic/arabi-add/README arabi-add.license = [ "lppl13c" ]; @@ -254,13 +255,38 @@ in # Pre-defined combined packages for TeX Live schemes, # to make nix-env usage more comfortable and build selected on Hydra. - combined = with lib; recurseIntoAttrs ( + combined = with lib; + let + # these license lists should be the sorted union of the licenses of the packages the schemes contain. + # The correctness of this collation is tested by tests.texlive.licenses + licenses = with lib.licenses; { + scheme-basic = [ free gfl gpl1Only gpl2 gpl2Plus knuth lgpl21 lppl1 lppl13c mit ofl publicDomain ]; + scheme-context = [ bsd2 bsd3 cc-by-sa-40 free gfl gfsl gpl1Only gpl2 gpl2Plus gpl3 gpl3Plus knuth lgpl2 lgpl21 + lppl1 lppl13c mit ofl publicDomain x11 ]; + scheme-full = [ artistic1 artistic1-cl8 asl20 bsd2 bsd3 bsdOriginal cc-by-10 cc-by-40 cc-by-sa-10 cc-by-sa-20 + cc-by-sa-30 cc-by-sa-40 cc0 fdl13Only free gfl gfsl gpl1Only gpl1Plus gpl2 gpl2Plus gpl3 gpl3Plus isc knuth + lgpl2 lgpl21 lgpl3 lppl1 lppl12 lppl13a lppl13c mit ofl publicDomain x11 ]; + scheme-gust = [ artistic1-cl8 asl20 bsd2 bsd3 cc-by-40 cc-by-sa-40 cc0 fdl13Only free gfl gfsl gpl1Only gpl2 + gpl2Plus gpl3 gpl3Plus knuth lgpl2 lgpl21 lppl1 lppl12 lppl13a lppl13c mit ofl publicDomain x11 ]; + scheme-infraonly = [ gpl2 lgpl21 ]; + scheme-medium = [ artistic1-cl8 asl20 bsd2 bsd3 cc-by-40 cc-by-sa-20 cc-by-sa-30 cc-by-sa-40 cc0 fdl13Only + free gfl gpl1Only gpl2 gpl2Plus gpl3 gpl3Plus isc knuth lgpl2 lgpl21 lgpl3 lppl1 lppl12 lppl13a lppl13c mit ofl + publicDomain x11 ]; + scheme-minimal = [ free gpl1Only gpl2 gpl2Plus knuth lgpl21 lppl1 lppl13c mit ofl publicDomain ]; + scheme-small = [ asl20 cc-by-40 cc-by-sa-40 cc0 fdl13Only free gfl gpl1Only gpl2 gpl2Plus gpl3 gpl3Plus knuth + lgpl2 lgpl21 lppl1 lppl12 lppl13a lppl13c mit ofl publicDomain x11 ]; + scheme-tetex = [ artistic1-cl8 asl20 bsd2 bsd3 cc-by-40 cc-by-sa-10 cc-by-sa-20 cc-by-sa-30 cc-by-sa-40 cc0 + fdl13Only free gfl gpl1Only gpl2 gpl2Plus gpl3 gpl3Plus isc knuth lgpl2 lgpl21 lgpl3 lppl1 lppl12 lppl13a + lppl13c mit ofl publicDomain x11]; + }; + in recurseIntoAttrs ( mapAttrs (pname: attrs: addMetaAttrs rec { description = "TeX Live environment for ${pname}"; platforms = lib.platforms.all; maintainers = with lib.maintainers; [ veprbl ]; + license = licenses.${pname}; } (combine { ${pname} = attrs;