This type correctly merges multiple option types together while also annotating them with file information. In a future commit this will be used for `_module.freeformType`main
parent
891e65b0fa
commit
5cbeddfde4
@ -0,0 +1,28 @@ |
||||
{ config, lib, ... }: { |
||||
|
||||
_file = "optionTypeFile.nix"; |
||||
|
||||
options.theType = lib.mkOption { |
||||
type = lib.types.optionType; |
||||
}; |
||||
|
||||
options.theOption = lib.mkOption { |
||||
type = config.theType; |
||||
default = {}; |
||||
}; |
||||
|
||||
config.theType = lib.mkMerge [ |
||||
(lib.types.submodule { |
||||
options.nested = lib.mkOption { |
||||
type = lib.types.int; |
||||
}; |
||||
}) |
||||
(lib.types.submodule { |
||||
_file = "other.nix"; |
||||
options.nested = lib.mkOption { |
||||
type = lib.types.str; |
||||
}; |
||||
}) |
||||
]; |
||||
|
||||
} |
@ -0,0 +1,27 @@ |
||||
{ config, lib, ... }: { |
||||
|
||||
options.theType = lib.mkOption { |
||||
type = lib.types.optionType; |
||||
}; |
||||
|
||||
options.theOption = lib.mkOption { |
||||
type = config.theType; |
||||
}; |
||||
|
||||
config.theType = lib.mkMerge [ |
||||
(lib.types.submodule { |
||||
options.int = lib.mkOption { |
||||
type = lib.types.int; |
||||
default = 10; |
||||
}; |
||||
}) |
||||
(lib.types.submodule { |
||||
options.str = lib.mkOption { |
||||
type = lib.types.str; |
||||
}; |
||||
}) |
||||
]; |
||||
|
||||
config.theOption.str = "hello"; |
||||
|
||||
} |
Loading…
Reference in new issue