diff options
author | Shea Levy <shea@shealevy.com> | 2024-01-30 17:29:47 -0500 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2024-02-02 16:27:30 -0500 |
commit | ca1262a4832b290d9f35c4b9c5f67f93144c7f2a (patch) | |
tree | 4f6bea9f271666da958a0531adb7ede78df05d0b /lib/tests | |
parent | 5b5e6f990070ec0c5c343ff9160554866ecd23c2 (diff) |
lib: Add optionalDrvAttr to conditionally set drv attributes.
This allows for adding new, conditionally set, derivation attributes to an existing derivation without changing any output paths in the case where the condition is not met.
Diffstat (limited to 'lib/tests')
-rw-r--r-- | lib/tests/misc.nix | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index 3059878ba0695..193e68a96933c 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -1902,7 +1902,7 @@ runTests { expected = true; }; - # lazyDerivation + # DERIVATIONS testLazyDerivationIsLazyInDerivationForAttrNames = { expr = attrNames (lazyDerivation { @@ -1955,6 +1955,24 @@ runTests { expected = derivation; }; + testOptionalDrvAttr = let + mkDerivation = args: derivation (args // { + builder = "builder"; + system = "system"; + __ignoreNulls = true; + }); + in { + expr = (mkDerivation { + name = "foo"; + x = optionalDrvAttr true 1; + y = optionalDrvAttr false 1; + }).drvPath; + expected = (mkDerivation { + name = "foo"; + x = 1; + }).drvPath; + }; + testTypeDescriptionInt = { expr = (with types; int).description; expected = "signed integer"; |