From 637c1c82bfb005a48d2a0e9defe2c93b95d8f71d Mon Sep 17 00:00:00 2001 From: Vincenzo Mantova <1962985+xworld21@users.noreply.github.com> Date: Sun, 12 May 2024 19:00:07 +0100 Subject: [PATCH] texlivePackages: use proper multioutput derivations TeX Live packages under `texlivePackages` are now left as simple multioutput derivations (without changes done in `passthru`). This should ensure that all outputs are copied in the binary caches. --- .../tex/texlive/build-texlive-package.nix | 47 +++++++++++-------- pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/pkgs/tools/typesetting/tex/texlive/build-texlive-package.nix b/pkgs/tools/typesetting/tex/texlive/build-texlive-package.nix index c5a55cf0f9c9..e289f9171c15 100644 --- a/pkgs/tools/typesetting/tex/texlive/build-texlive-package.nix +++ b/pkgs/tools/typesetting/tex/texlive/build-texlive-package.nix @@ -62,7 +62,7 @@ let # TeX Live packages should not be installed directly into the user profile outputsToInstall = [ ]; longDescription = '' - This package cannot be installed directly. Please use `texlive.withPackages`. + This package cannot be installed or used directly. Please use `texlive.withPackages (ps: [ ps.${lib.strings.escapeNixIdentifier pname} ])`. ''; # discourage nix-env from matching this package priority = 10; @@ -152,7 +152,7 @@ let # fake derivation for resolving dependencies in the absence of a "tex" containers fakeTeX = passthru - // { inherit meta; tlOutputName = "tex"; } + // { inherit meta; tlOutputName = "tex"; inherit build; } // outputDrvs; containers = rec { @@ -214,22 +214,31 @@ let ln -s {"$texdoc"/doc,"$out"/share}/info '') [ "out" ] // outputDrvs; }; -in -if outputs == [ ] then removeAttrs fakeTeX [ "outputSpecified" ] else -runCommand name - { - __structuredAttrs = true; - inherit meta outputDrvs outputs; - passthru = removeAttrs passthru [ "outputSpecified" ]; - # force output name in case "out" is missing - nativeBuildInputs = lib.optional (! hasBinfiles) - (writeShellScript "force-output.sh" '' + # multioutput derivation to be exported under texlivePackages + # to make Hydra build all containers + build = runCommand name + { + __structuredAttrs = true; + inherit meta outputDrvs; + outputs = if outputs != [ ] then outputs else [ "out" ]; + passthru = removeAttrs passthru [ "outputSpecified" ] // { inherit build; }; + + # force output name in case "out" is missing + preHook = lib.optionalString (!hasBinfiles && outputs != [ ]) '' export out="''${${builtins.head outputs}-}" - ''); - } - '' - for outputName in ''${!outputs[@]} ; do - ln -s "''${outputDrvs[$outputName]}" "''${outputs[$outputName]}" - done - '' // outputDrvs + ''; + } + # each output is just a symlink to the corresponding container + # if the container is missing (that is, outputs == [ ]), create a file, to prevent passing the package to .withPackages + '' + for outputName in ''${!outputs[@]} ; do + if [[ -z ''${outputDrvs[$outputName]} ]] ; then + ln -s "''${outputDrvs[$outputName]}" "''${outputs[$outputName]}" + else + touch "''${outputs[$outputName]}" + fi + done + ''; +in +if outputs == [ ] then removeAttrs fakeTeX [ "outputSpecified" ] else build // outputDrvs diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 17d0a42d7245..0e6e1b5fa47e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5313,7 +5313,7 @@ with pkgs; # TeX Live; see https://nixos.org/nixpkgs/manual/#sec-language-texlive texlive = callPackage ../tools/typesetting/tex/texlive { }; inherit (texlive.schemes) texliveBasic texliveBookPub texliveConTeXt texliveFull texliveGUST texliveInfraOnly texliveMedium texliveMinimal texliveSmall texliveTeTeX; - texlivePackages = recurseIntoAttrs (lib.filterAttrs (_: lib.isDerivation) texlive.pkgs); + texlivePackages = recurseIntoAttrs (lib.mapAttrs (_: v: v.build) texlive.pkgs); fop = callPackage ../tools/typesetting/fop { };