summaryrefslogtreecommitdiffstats
path: root/lib/tests/modules/name-merge-attrsWith-1.nix
blob: bbfd5fe0bddecc2a2edf019813c76787d3f198c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{ lib, ... }:
let
  inherit (lib) types mkOption;
in
{
  imports = [
    # Module A
    (
      { ... }:
      {
        options.mergedName = mkOption {
          default = { };
          type = types.attrsWith {
            placeholder = "id"; # <- This is beeing tested
            elemType = types.submodule {
              options.nested = mkOption {
                type = types.int;
                default = 1;
              };
            };
          };
        };
      }
    )
    # Module B
    (
      { ... }:
      {
        # defines the default placeholder "name"
        # type merging should resolve to "id"
        options.mergedName = mkOption {
          type = types.attrsOf (types.submodule { });
        };
      }
    )

    # Output
    (
      {
        options,
        ...
      }:
      {
        options.result = mkOption {
          default = lib.concatStringsSep "." (options.mergedName.type.getSubOptions options.mergedName.loc)
          .nested.loc;
        };
      }
    )
  ];
}