about summary refs log tree commit diff
path: root/lib/tests/modules/types-unique.nix
blob: 115be01269759a1a35127d5cd7fbeb81f9591d5b (plain) (blame)
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
{ 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;
    };
  };
}