summary refs log tree commit diff
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2016-03-14 11:56:03 +0100
committerVladimír Čunát <vcunat@gmail.com>2016-04-07 15:59:43 +0200
commit3342f717da7f660b4695f09034abc175a14fda24 (patch)
tree478cac285a4f5a477b9b91931e2974656ad40729
parentd6b46ecb30f1a18a4b08ed29f03d2b5a6941aec4 (diff)
downloadnixlib-3342f717da7f660b4695f09034abc175a14fda24.tar
nixlib-3342f717da7f660b4695f09034abc175a14fda24.tar.gz
nixlib-3342f717da7f660b4695f09034abc175a14fda24.tar.bz2
nixlib-3342f717da7f660b4695f09034abc175a14fda24.tar.lz
nixlib-3342f717da7f660b4695f09034abc175a14fda24.tar.xz
nixlib-3342f717da7f660b4695f09034abc175a14fda24.tar.zst
nixlib-3342f717da7f660b4695f09034abc175a14fda24.zip
stdenv: set meta.outputsToInstall unless overridden
-rw-r--r--pkgs/stdenv/generic/default.nix22
1 files changed, 16 insertions, 6 deletions
diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix
index 8395394f5a87..90cacd036c2a 100644
--- a/pkgs/stdenv/generic/default.nix
+++ b/pkgs/stdenv/generic/default.nix
@@ -220,12 +220,22 @@ let
         # The meta attribute is passed in the resulting attribute set,
         # but it's not part of the actual derivation, i.e., it's not
         # passed to the builder and is not a dependency.  But since we
-        # include it in the result, it *is* available to nix-env for
-        # queries.  We also a meta.position attribute here to
-        # identify the source location of the package.
-        meta = meta // (if pos' != null then {
-          position = pos'.file + ":" + toString pos'.line;
-        } else {});
+        # include it in the result, it *is* available to nix-env for queries.
+        meta = { }
+            # If the packager hasn't specified `outputsToInstall`, choose a default,
+            # namely `p.bin or p.out or p`;
+            # if he has specified it, it will be overridden below in `// meta`.
+          // { outputsToInstall =
+            let
+              outs = outputs'; # the value passed to derivation primitive
+              hasOutput = out: builtins.elem out outs;
+            in [( lib.findFirst hasOutput null (["bin" "out"] ++ outs) )];
+          }
+          // meta
+            # Fill `meta.position` to identify the source location of the package.
+          // lib.optionalAttrs (pos' != null)
+            { position = pos'.file + ":" + toString pos'.line; }
+          ;
         inherit passthru;
       } //
       # Pass through extra attributes that are not inputs, but