summaryrefslogtreecommitdiffstats
path: root/lib/tests/modules/specialArgs-lib.nix
blob: 4e87b22e54d1fb9869dddfd23b80e236cf622e00 (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
{ config, lib, ... }:

{
  options = {
    result = lib.mkOption { };
    weird = lib.mkOption {
      type = lib.types.submoduleWith {
        # I generally recommend against overriding lib, because that leads to
        # slightly incompatible dialects of the module system.
        # Nonetheless, it's worth guarding the property that the module system
        # evaluates with a completely custom lib, as a matter of separation of
        # concerns.
        specialArgs.lib = { };
        modules = [ ];
      };
    };
  };
  config.weird =
    args@{
      ... # note the lack of a `lib` argument
    }:
    assert args.lib == { };
    assert args.specialArgs == { lib = { }; };
    {
      options.foo = lib.mkOption { };
      config.foo = lib.mkIf true "alright";
    };
  config.result =
    assert config.weird.foo == "alright";
    "ok";
}