mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 17:46:29 +09:00
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.
This commit is contained in:
parent
5b5e6f9900
commit
ca1262a483
4 changed files with 47 additions and 2 deletions
|
@ -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";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue