From bb0aaf91cc5cd31f3a7b5c5b3ca397f8f5338e81 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Thu, 23 Apr 2026 17:57:30 -0500 Subject: [PATCH] tests: split stub derivation attrs from methods Apply non-function stub attributes through overrideAttrs so derivation metadata and wrapper-facing fields remain visible to downstream consumers. Keep function-valued attributes like override on the outer attrset so they are not serialized into derivations and do not break unrelated tests. --- tests/stubs.nix | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/stubs.nix b/tests/stubs.nix index 24158c2c3..078a760fd 100644 --- a/tests/stubs.nix +++ b/tests/stubs.nix @@ -64,8 +64,19 @@ let meta.mainProgram = name; } buildScript; + drvExtraAttrs = lib.filterAttrs (_: v: !lib.isFunction v) extraAttrs; + + outerExtraAttrs = lib.filterAttrs (_: lib.isFunction) extraAttrs; + + overriddenPkg = + if drvExtraAttrs == { } then + pkg + else + pkg.overrideAttrs (old: lib.recursiveUpdate old drvExtraAttrs); + stubbedPkg = - pkg + overriddenPkg + // outerExtraAttrs // lib.optionalAttrs (outPath != null) { inherit outPath; @@ -74,12 +85,11 @@ let # Allow the original package to be used in derivation inputs __spliced = { - buildHost = pkg; - hostTarget = pkg; + buildHost = overriddenPkg; + hostTarget = overriddenPkg; }; } - // lib.optionalAttrs (version != null) { inherit version; } - // extraAttrs; + // lib.optionalAttrs (version != null) { inherit version; }; in stubbedPkg;