diff options
author | Robert Hensing <robert@roberthensing.nl> | 2022-05-13 08:59:27 +0200 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2022-05-13 09:01:05 +0200 |
commit | 06da97fc3a753e0bbebc03ebd63bb1bde2cdda03 (patch) | |
tree | 7983cda12b7a622357d2964d54b7ac37c091bf57 /lib/tests/modules | |
parent | f771d397500b5138329bd206af2634086d51d108 (diff) |
lib.types.functionTo: Support type merging
Diffstat (limited to 'lib/tests/modules')
-rw-r--r-- | lib/tests/modules/functionTo/submodule-options.nix | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/lib/tests/modules/functionTo/submodule-options.nix b/lib/tests/modules/functionTo/submodule-options.nix new file mode 100644 index 0000000000000..7bf7082315046 --- /dev/null +++ b/lib/tests/modules/functionTo/submodule-options.nix @@ -0,0 +1,59 @@ +{ lib, config, options, ... }: +let + inherit (lib) types; +in +{ + imports = [ + + # fun.<function-body>.a + ({ ... }: { + options = { + fun = lib.mkOption { + type = types.functionTo (types.submodule { + options.a = lib.mkOption { }; + }); + }; + }; + }) + + # fun.<function-body>.b + ({ ... }: { + options = { + fun = lib.mkOption { + type = types.functionTo (types.submodule { + options.b = lib.mkOption { }; + }); + }; + }; + }) + ]; + + options = { + result = lib.mkOption + { + type = types.str; + default = lib.concatStringsSep " " + (lib.concatLists + (lib.mapAttrsToList + (k: v: + if k == "_module" + then [ ] + else [ (lib.showOption v.loc) ] + ) + ( + (options.fun.type.getSubOptions [ "fun" ]) + ) + ) + ); + }; + }; + + config.fun = lib.mkMerge + [ + (input: { inherit (input) a; }) + (input: { inherit (input) b; }) + (input: { + b = lib.mkForce input.c; + }) + ]; +} |