summary refs log tree commit diff
path: root/pkgs/stdenv/generic/default.nix
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2017-01-29 12:07:44 +0100
committerJohn Ericson <John.Ericson@Obsidian.Systems>2017-07-07 12:02:29 -0400
commit7fdf18e8928870d6e015ad8aadc4a3e856076f18 (patch)
tree0136345161ad25e5384863e9dc3dae3583258fe4 /pkgs/stdenv/generic/default.nix
parent74f55017d26bb0931184bbcb54630000ce5ee107 (diff)
downloadnixpkgs-7fdf18e8928870d6e015ad8aadc4a3e856076f18.tar
nixpkgs-7fdf18e8928870d6e015ad8aadc4a3e856076f18.tar.gz
nixpkgs-7fdf18e8928870d6e015ad8aadc4a3e856076f18.tar.bz2
nixpkgs-7fdf18e8928870d6e015ad8aadc4a3e856076f18.tar.lz
nixpkgs-7fdf18e8928870d6e015ad8aadc4a3e856076f18.tar.xz
nixpkgs-7fdf18e8928870d6e015ad8aadc4a3e856076f18.tar.zst
nixpkgs-7fdf18e8928870d6e015ad8aadc4a3e856076f18.zip
stdenv: refactor (no change in semantics)
This just moves some expressions around in preparation to further changes.
Diffstat (limited to 'pkgs/stdenv/generic/default.nix')
-rw-r--r--pkgs/stdenv/generic/default.nix75
1 files changed, 41 insertions, 34 deletions
diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix
index ce9beb2bbc6..8db0017f2d9 100644
--- a/pkgs/stdenv/generic/default.nix
+++ b/pkgs/stdenv/generic/default.nix
@@ -290,15 +290,15 @@ let
         in [ nativeBuildInputs buildInputs ];
 
       propagatedDependencies' = map lib.chooseDevOutputs propagatedDependencies;
-    in
 
       # Throw an error if trying to evaluate an non-valid derivation
-      assert let v = checkValidity attrs;
+      validityCondition =
+			 let v = checkValidity attrs;
              in if !v.valid
                then throwEvalHelp (removeAttrs v ["valid"])
                else true;
 
-      lib.addPassthru (derivation (
+      derivationArg =
         (removeAttrs attrs
           ["meta" "passthru" "crossAttrs" "pos"
            "__impureHostDeps" "__propagatedImpureHostDeps"
@@ -343,37 +343,44 @@ let
           __propagatedImpureHostDeps = computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps;
         } // (if outputs' != [ "out" ] then {
           outputs = outputs';
-        } else { })))) (
-      {
-        overrideAttrs = f: mkDerivation (attrs // (f attrs));
-        # 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 = { }
-            # If the packager hasn't specified `outputsToInstall`, choose a default,
-            # which is the name of `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
-      # should be made available to Nix expressions using the
-      # derivation (e.g., in assertions).
-      passthru);
+        } else { }));
+
+      # 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 = { }
+          # If the packager hasn't specified `outputsToInstall`, choose a default,
+          # which is the name of `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) )];
+        }
+        // attrs.meta or {}
+          # Fill `meta.position` to identify the source location of the package.
+        // lib.optionalAttrs (pos' != null)
+          { position = pos'.file + ":" + toString pos'.line; }
+        ;
+
+    in
+
+      assert validityCondition;
+
+      lib.addPassthru (derivation derivationArg) (
+        {
+          overrideAttrs = f: mkDerivation (attrs // (f attrs));
+          inherit meta passthru;
+        } //
+        # Pass through extra attributes that are not inputs, but
+        # should be made available to Nix expressions using the
+        # derivation (e.g., in assertions).
+        passthru);
 
   # The stdenv that we are producing.
   result =