about summary refs log tree commit diff
path: root/pkgs/stdenv/generic
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2016-04-07 16:00:09 +0200
committerVladimír Čunát <vcunat@gmail.com>2016-04-07 16:00:09 +0200
commit710573ce6d3478e843ac4891d95185eadba6bd5e (patch)
treeb044be2f760e82dd19977fc40500541b52d93c1c /pkgs/stdenv/generic
parentd1df28f8e5b98be01417ffc1032020415390f2a0 (diff)
parent9a824f2f1dd01450e6f7270246f77210d4c9c2a5 (diff)
Merge #12653: rework default outputs
Diffstat (limited to 'pkgs/stdenv/generic')
-rw-r--r--pkgs/stdenv/generic/default.nix25
1 files changed, 19 insertions, 6 deletions
diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix
index 8395394f5a873..547541d28246e 100644
--- a/pkgs/stdenv/generic/default.nix
+++ b/pkgs/stdenv/generic/default.nix
@@ -220,12 +220,25 @@ 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`.
+            #   Note: This default probably shouldn't be globally configurable.
+            #   Services and users should specify outputs explicitly,
+            #   unless they are comfortable with this default.
+          // { 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