about summary refs log tree commit diff
path: root/pkgs/stdenv
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2013-03-02 08:34:53 -0500
committerShea Levy <shea@shealevy.com>2013-03-02 08:34:53 -0500
commit0a7d8a5175df2861d0e56b37dddf4114d7a9849c (patch)
tree5925daa5cd0b498d73489217b3269342303f5094 /pkgs/stdenv
parentb90b62e33b648e48bf5ef794e0b1c032f391df43 (diff)
downloadnixlib-0a7d8a5175df2861d0e56b37dddf4114d7a9849c.tar
nixlib-0a7d8a5175df2861d0e56b37dddf4114d7a9849c.tar.gz
nixlib-0a7d8a5175df2861d0e56b37dddf4114d7a9849c.tar.bz2
nixlib-0a7d8a5175df2861d0e56b37dddf4114d7a9849c.tar.lz
nixlib-0a7d8a5175df2861d0e56b37dddf4114d7a9849c.tar.xz
nixlib-0a7d8a5175df2861d0e56b37dddf4114d7a9849c.tar.zst
nixlib-0a7d8a5175df2861d0e56b37dddf4114d7a9849c.zip
stdenv.mkDerivation: Add meta and passthru to all outputs.
Before, only the first output (and not even that when accessed through 'all' or its corresponding attribtue) had meta information and the relevant passthru attributes.

This doesn't change stdenv's hash and the tarball still builds, I'm pretty sure this is safe for master.
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r--pkgs/stdenv/generic/default.nix88
1 files changed, 52 insertions, 36 deletions
diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix
index 3106beed1c5b..facea368c051 100644
--- a/pkgs/stdenv/generic/default.nix
+++ b/pkgs/stdenv/generic/default.nix
@@ -44,42 +44,58 @@ let
           if !allowUnfree && (let l = attrs.meta.license or ""; in l == "unfree" || l == "unfree-redistributable" || l == lib.licenses.proprietary) then
             throw "package ‘${attrs.name}’ has an unfree license, refusing to evaluate"
           else
-          (derivation (
-            (removeAttrs attrs ["meta" "passthru" "crossAttrs"])
-            // (let
-              buildInputs = attrs.buildInputs or [];
-              buildNativeInputs = attrs.buildNativeInputs or [];
-              propagatedBuildInputs = attrs.propagatedBuildInputs or [];
-              propagatedBuildNativeInputs = attrs.propagatedBuildNativeInputs or [];
-              crossConfig = attrs.crossConfig or null;
-            in
-            {
-              builder = attrs.realBuilder or shell;
-              args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)];
-              stdenv = result;
-              system = result.system;
-
-              # Inputs built by the cross compiler.
-              buildInputs = lib.optionals (crossConfig != null) buildInputs;
-              propagatedBuildInputs = lib.optionals (crossConfig != null)
-                  propagatedBuildInputs;
-              # Inputs built by the usual native compiler.
-              buildNativeInputs = buildNativeInputs ++ lib.optionals
-                (crossConfig == null) buildInputs;
-              propagatedBuildNativeInputs = propagatedBuildNativeInputs ++
-                lib.optionals (crossConfig == null) propagatedBuildInputs;
-            }))
-          )
-          # 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.
-          // { meta = attrs.meta or {}; }
-          # Pass through extra attributes that are not inputs, but
-          # should be made available to Nix expressions using the
-          # derivation (e.g., in assertions).
-          // (attrs.passthru or {});
+            let
+              drv = derivation (
+                (removeAttrs attrs ["meta" "passthru" "crossAttrs"])
+                // (let
+                  buildInputs = attrs.buildInputs or [];
+                  buildNativeInputs = attrs.buildNativeInputs or [];
+                  propagatedBuildInputs = attrs.propagatedBuildInputs or [];
+                  propagatedBuildNativeInputs = attrs.propagatedBuildNativeInputs or [];
+                  crossConfig = attrs.crossConfig or null;
+                in
+                {
+                  builder = attrs.realBuilder or shell;
+                  args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)];
+                  stdenv = result;
+                  system = result.system;
+
+                  # Inputs built by the cross compiler.
+                  buildInputs = lib.optionals (crossConfig != null) buildInputs;
+                  propagatedBuildInputs = lib.optionals (crossConfig != null)
+                      propagatedBuildInputs;
+                  # Inputs built by the usual native compiler.
+                  buildNativeInputs = buildNativeInputs ++ lib.optionals
+                    (crossConfig == null) buildInputs;
+                  propagatedBuildNativeInputs = propagatedBuildNativeInputs ++
+                    lib.optionals (crossConfig == null) propagatedBuildInputs;
+              }));
+
+              outputs = drv.outputs or [ "out" ];
+
+              commonAttrs = drv // (builtins.listToAttrs outputsList) //
+                ({ all = map (x: x.value) outputsList;
+                  # 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.
+                  meta = attrs.meta or {};
+                }) //
+                # Pass through extra attributes that are not inputs, but
+                # should be made available to Nix expressions using the
+                # derivation (e.g., in assertions).
+                (attrs.passthru or {});
+
+              outputToAttrListElement = outputName:
+                { name = outputName;
+                  value = commonAttrs // {
+                    inherit (builtins.getAttr outputName drv) outPath drvPath type outputName;
+                  };
+                };
+
+              outputsList = map outputToAttrListElement outputs;
+            in (builtins.head outputsList).value;
 
         # Utility flags to test the type of platform.
         isDarwin = result.system == "x86_64-darwin";