diff options
author | Silvan Mosberger <contact@infinisil.com> | 2021-10-02 16:37:22 +0200 |
---|---|---|
committer | Silvan Mosberger <contact@infinisil.com> | 2021-10-02 16:37:22 +0200 |
commit | 48293bd6b6b791b9af745e9b7b94a6856e279fa0 (patch) | |
tree | 0ea4d2706a5503ce6837fcb81d4e841d1b28c403 /lib/tests | |
parent | 54e1db21522a61ca771aeafbbd77c4a474e82f8e (diff) | |
download | nixpkgs-48293bd6b6b791b9af745e9b7b94a6856e279fa0.tar nixpkgs-48293bd6b6b791b9af745e9b7b94a6856e279fa0.tar.gz nixpkgs-48293bd6b6b791b9af745e9b7b94a6856e279fa0.tar.bz2 nixpkgs-48293bd6b6b791b9af745e9b7b94a6856e279fa0.tar.lz nixpkgs-48293bd6b6b791b9af745e9b7b94a6856e279fa0.tar.xz nixpkgs-48293bd6b6b791b9af745e9b7b94a6856e279fa0.tar.zst nixpkgs-48293bd6b6b791b9af745e9b7b94a6856e279fa0.zip |
lib/types: Make types.anything merge functions
Previously it would give an error if there were multiple function definitions.
Diffstat (limited to 'lib/tests')
-rwxr-xr-x | lib/tests/modules.sh | 4 | ||||
-rw-r--r-- | lib/tests/modules/types-anything/functions.nix | 12 |
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index 2e57c2f8e2a..b51db91f6b0 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -254,8 +254,10 @@ checkConfigOutput / config.value.path ./types-anything/equal-atoms.nix checkConfigOutput null config.value.null ./types-anything/equal-atoms.nix checkConfigOutput 0.1 config.value.float ./types-anything/equal-atoms.nix # Functions can't be merged together -checkConfigError "The option .* has conflicting definition values" config.value.multiple-lambdas ./types-anything/functions.nix +checkConfigError "The option .value.multiple-lambdas.<function body>. has conflicting option types" config.applied.multiple-lambdas ./types-anything/functions.nix checkConfigOutput '<LAMBDA>' config.value.single-lambda ./types-anything/functions.nix +checkConfigOutput 'null' config.applied.merging-lambdas.x ./types-anything/functions.nix +checkConfigOutput 'null' config.applied.merging-lambdas.y ./types-anything/functions.nix # Check that all mk* modifiers are applied checkConfigError 'attribute .* not found' config.value.mkiffalse ./types-anything/mk-mods.nix checkConfigOutput '{ }' config.value.mkiftrue ./types-anything/mk-mods.nix diff --git a/lib/tests/modules/types-anything/functions.nix b/lib/tests/modules/types-anything/functions.nix index 07951891391..21edd4aff9c 100644 --- a/lib/tests/modules/types-anything/functions.nix +++ b/lib/tests/modules/types-anything/functions.nix @@ -1,16 +1,22 @@ -{ lib, ... }: { +{ lib, config, ... }: { options.value = lib.mkOption { type = lib.types.anything; }; + options.applied = lib.mkOption { + default = lib.mapAttrs (name: fun: fun null) config.value; + }; + config = lib.mkMerge [ { value.single-lambda = x: x; - value.multiple-lambdas = x: x; + value.multiple-lambdas = x: { inherit x; }; + value.merging-lambdas = x: { inherit x; }; } { - value.multiple-lambdas = x: x; + value.multiple-lambdas = x: [ x ]; + value.merging-lambdas = y: { inherit y; }; } ]; |