summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2018-01-14 21:35:50 +0100
committerVladimír Čunát <vcunat@gmail.com>2018-01-14 21:41:31 +0100
commit67e8392383d29c8dd4a7392bef33e0c16ac2297f (patch)
treef039586d277183e3aeb3784efb24549056c43ee8 /lib
parent1a054480d312a40feba4f579eec3cd2d0db21280 (diff)
parent799b941a2bb61970d6b99366bcf2062f1ce14328 (diff)
downloadnixpkgs-67e8392383d29c8dd4a7392bef33e0c16ac2297f.tar
nixpkgs-67e8392383d29c8dd4a7392bef33e0c16ac2297f.tar.gz
nixpkgs-67e8392383d29c8dd4a7392bef33e0c16ac2297f.tar.bz2
nixpkgs-67e8392383d29c8dd4a7392bef33e0c16ac2297f.tar.lz
nixpkgs-67e8392383d29c8dd4a7392bef33e0c16ac2297f.tar.xz
nixpkgs-67e8392383d29c8dd4a7392bef33e0c16ac2297f.tar.zst
nixpkgs-67e8392383d29c8dd4a7392bef33e0c16ac2297f.zip
Merge #33057: stdenv meta checks: make them lazy
Closes #22277 - it's superseded;  I have some WIP on evaluation
performance, but best do that in a separate PR/thread.
Diffstat (limited to 'lib')
-rw-r--r--lib/customisation.nix20
-rw-r--r--lib/default.nix3
2 files changed, 17 insertions, 6 deletions
diff --git a/lib/customisation.nix b/lib/customisation.nix
index 483ef6fd486..fb78335ea1c 100644
--- a/lib/customisation.nix
+++ b/lib/customisation.nix
@@ -36,7 +36,7 @@ rec {
   overrideDerivation = drv: f:
     let
       newDrv = derivation (drv.drvAttrs // (f drv));
-    in addPassthru newDrv (
+    in lib.flip (extendDerivation true) newDrv (
       { meta = drv.meta or {};
         passthru = if drv ? passthru then drv.passthru else {};
       }
@@ -131,8 +131,8 @@ rec {
 
 
   /* Add attributes to each output of a derivation without changing
-     the derivation itself. */
-  addPassthru = drv: passthru:
+     the derivation itself and check a given condition when evaluating. */
+  extendDerivation = condition: passthru: drv:
     let
       outputs = drv.outputs or [ "out" ];
 
@@ -142,13 +142,23 @@ rec {
       outputToAttrListElement = outputName:
         { name = outputName;
           value = commonAttrs // {
-            inherit (drv.${outputName}) outPath drvPath type outputName;
+            inherit (drv.${outputName}) type outputName;
+            drvPath = assert condition; drv.${outputName}.drvPath;
+            outPath = assert condition; drv.${outputName}.outPath;
           };
         };
 
       outputsList = map outputToAttrListElement outputs;
-  in commonAttrs // { outputUnspecified = true; };
+    in commonAttrs // {
+      outputUnspecified = true;
+      drvPath = assert condition; drv.drvPath;
+      outPath = assert condition; drv.outPath;
+    };
 
+  /* Add attributes to each output of a derivation without changing
+     the derivation itself. */
+  addPassthru = lib.warn "`addPassthru` is deprecated, replace with `extendDerivation true`"
+                         (extendDerivation true);
 
   /* Strip a derivation of all non-essential attributes, returning
      only those needed by hydra-eval-jobs. Also strictly evaluate the
diff --git a/lib/default.nix b/lib/default.nix
index 03a902945a3..6d2a95e559c 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -87,7 +87,8 @@ let
     inherit (stringsWithDeps) textClosureList textClosureMap
       noDepEntry fullDepEntry packEntry stringAfter;
     inherit (customisation) overrideDerivation makeOverridable
-      callPackageWith callPackagesWith addPassthru hydraJob makeScope;
+      callPackageWith callPackagesWith extendDerivation addPassthru
+      hydraJob makeScope;
     inherit (meta) addMetaAttrs dontDistribute setName updateName
       appendToName mapDerivationAttrset lowPrio lowPrioSet hiPrio
       hiPrioSet;