about summary refs log tree commit diff
path: root/nix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-02-02T10·19+0300
committertazjin <tazjin@tvl.su>2022-02-02T13·36+0000
commitba7197c271d54fd806970738e883b39c8ae1a3a9 (patch)
tree77171a4cb123014461239bd405dd8e6b1339887a /nix
parent5540c80d87a0f5653b7deaa111210b60af85449f (diff)
fix(nix/readTree): Use overrideAttrs with derivations r/3742
Derivations that support overrideAttrs now have their readTree
markers merged in using it, as passthru attributes.

This makes the significant difference that overriding readTree targets
using `overrideAttrs` keeps their readTree data intact.

Change-Id: Ieef635f048781bf4782c1a28532b89a66d9ca24d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5186
Tested-by: BuildkiteCI
Reviewed-by: ezemtsov <eugene.zemtsov@gmail.com>
Autosubmit: tazjin <tazjin@tvl.su>
Diffstat (limited to 'nix')
-rw-r--r--nix/readTree/default.nix15
1 files changed, 13 insertions, 2 deletions
diff --git a/nix/readTree/default.nix b/nix/readTree/default.nix
index 0c59c890d4..22815a44c4 100644
--- a/nix/readTree/default.nix
+++ b/nix/readTree/default.nix
@@ -58,6 +58,17 @@ let
     __readTreeChildren = builtins.attrNames children;
   };
 
+  # Merge two attribute sets, but place attributes in `passthru` via
+  # `overrideAttrs` for derivation targets that support it.
+  merge = a: b:
+    if a ? overrideAttrs
+    then
+      a.overrideAttrs
+        (prev: {
+          passthru = (prev.passthru or { }) // b;
+        })
+    else a // b;
+
   # Import a file and enforce our calling convention
   importFile = args: scopedArgs: path: parts: filter:
     let
@@ -122,7 +133,7 @@ let
             name = c;
             value =
               if isAttrs imported
-              then imported // marker childParts { }
+              then merge imported (marker childParts { })
               else imported;
           })
         nixFiles;
@@ -137,7 +148,7 @@ let
 
     in
     if isAttrs nodeValue
-    then nodeValue // allChildren // (marker parts allChildren)
+    then merge nodeValue (allChildren // (marker parts allChildren))
     else nodeValue;
 
   # Function which can be used to find all readTree targets within an