summaryrefslogtreecommitdiffstats
path: root/lib/tests/modules/types-unique.nix
blob: 83efcbbb1595213886246a7a89ef55b40121b622 (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
{ lib, ... }:
let
  inherit (lib) mkOption types;
in
{
  options.examples = mkOption {
    type = types.lazyAttrsOf (
      types.unique {
        message = "We require a single definition, because seeing the whole value at once helps us maintain critical invariants of our system.";
      } (types.attrsOf types.str)
    );
  };
  imports = [
    {
      examples.merged = {
        b = "bee";
      };
    }
    { examples.override = lib.mkForce { b = "bee"; }; }
  ];
  config.examples = {
    merged = {
      a = "aye";
    };
    override = {
      a = "aye";
    };
    badLazyType = {
      a = true;
    };
  };
}