summary refs log tree commit diff
path: root/pkgs/build-support/buildenv/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/build-support/buildenv/default.nix')
-rw-r--r--pkgs/build-support/buildenv/default.nix14
1 files changed, 13 insertions, 1 deletions
diff --git a/pkgs/build-support/buildenv/default.nix b/pkgs/build-support/buildenv/default.nix
index 5de02c8ed25..8b2167a8e74 100644
--- a/pkgs/build-support/buildenv/default.nix
+++ b/pkgs/build-support/buildenv/default.nix
@@ -25,6 +25,10 @@
   # directories in the list is not symlinked.
   pathsToLink ? ["/"]
 
+, # The package outputs to include. By default, only the default
+  # output is included.
+  extraOutputsToInstall ? []
+
 , # Root the result in directory "$out${extraPrefix}", e.g. "/share".
   extraPrefix ? ""
 
@@ -43,7 +47,15 @@ runCommand name
     inherit manifest ignoreCollisions checkCollisionContents passthru
             meta pathsToLink extraPrefix postBuild buildInputs;
     pkgs = builtins.toJSON (map (drv: {
-      paths = [ drv ];
+      paths =
+        # First add the usual output(s): respect if user has chosen explicitly,
+        # and otherwise use `meta.outputsToInstall` (guaranteed to exist by stdenv).
+        (if (drv.outputUnspecified or false)
+          then map (outName: drv.${outName}) drv.meta.outputsToInstall
+          else [ drv ])
+        # Add any extra outputs specified by the caller of `buildEnv`.
+        ++ lib.filter (p: p!=null)
+          (builtins.map (outName: drv.${outName} or null) extraOutputsToInstall);
       priority = drv.meta.priority or 5;
     }) paths);
     preferLocalBuild = true;