mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-26 04:43:09 +03:00
Merge pull request #245271 from sternenseemann/module-system-merge-no-type
lib/modules: handle typeless options in mergeModules
This commit is contained in:
commit
19f1d7da06
@ -639,7 +639,7 @@ let
|
|||||||
unmatchedDefns = [];
|
unmatchedDefns = [];
|
||||||
}
|
}
|
||||||
else if optionDecls != [] then
|
else if optionDecls != [] then
|
||||||
if all (x: x.options.type.name == "submodule") optionDecls
|
if all (x: x.options.type.name or null == "submodule") optionDecls
|
||||||
# Raw options can only be merged into submodules. Merging into
|
# Raw options can only be merged into submodules. Merging into
|
||||||
# attrsets might be nice, but ambiguous. Suppose we have
|
# attrsets might be nice, but ambiguous. Suppose we have
|
||||||
# attrset as a `attrsOf submodule`. User declares option
|
# attrset as a `attrsOf submodule`. User declares option
|
||||||
|
@ -371,6 +371,9 @@ checkConfigError \
|
|||||||
config.set \
|
config.set \
|
||||||
./declare-set.nix ./declare-enable-nested.nix
|
./declare-set.nix ./declare-enable-nested.nix
|
||||||
|
|
||||||
|
# Check that that merging of option collisions doesn't depend on type being set
|
||||||
|
checkConfigError 'The option .group..*would be a parent of the following options, but its type .<no description>. does not support nested options.\n\s*- option.s. with prefix .group.enable..*' config.group.enable ./merge-typeless-option.nix
|
||||||
|
|
||||||
# Test that types.optionType merges types correctly
|
# Test that types.optionType merges types correctly
|
||||||
checkConfigOutput '^10$' config.theOption.int ./optionTypeMerging.nix
|
checkConfigOutput '^10$' config.theOption.int ./optionTypeMerging.nix
|
||||||
checkConfigOutput '^"hello"$' config.theOption.str ./optionTypeMerging.nix
|
checkConfigOutput '^"hello"$' config.theOption.str ./optionTypeMerging.nix
|
||||||
|
25
lib/tests/modules/merge-typeless-option.nix
Normal file
25
lib/tests/modules/merge-typeless-option.nix
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
typeless =
|
||||||
|
{ lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
options.group = lib.mkOption { };
|
||||||
|
};
|
||||||
|
childOfTypeless =
|
||||||
|
{ lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
options.group.enable = lib.mkEnableOption "nothing";
|
||||||
|
};
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
typeless
|
||||||
|
childOfTypeless
|
||||||
|
];
|
||||||
|
|
||||||
|
config.group.enable = false;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user