1{ lib, ... }:
2let
3 inherit (lib)
4 mkOption
5 mkDefinition
6 mkOptionDefault
7 ;
8in
9{
10 imports = [
11 {
12 _file = "file";
13 options.conflict = mkOption {
14 default = 1;
15 };
16 config.conflict = mkDefinition {
17 file = "other";
18 value = mkOptionDefault 42;
19 };
20 }
21 {
22 # Check that mkDefinition works within 'config'
23 options.viaConfig = mkOption { };
24 config.viaConfig = mkDefinition {
25 file = "other";
26 value = true;
27 };
28 }
29 {
30 # Check mkMerge can wrap mkDefinitions
31 # Not the other way around
32 options.mkMerge = mkOption {
33 type = lib.types.bool;
34 };
35 config.mkMerge = lib.mkMerge [
36 (mkDefinition {
37 file = "a.nix";
38 value = true;
39 })
40 (mkDefinition {
41 file = "b.nix";
42 value = true;
43 })
44 ];
45 }
46 {
47 # Check mkDefinition can use mkForce on the value
48 # Not the other way around
49 options.mkForce = mkOption {
50 type = lib.types.bool;
51 default = false;
52 };
53 config.mkForce = mkDefinition {
54 file = "other";
55 value = lib.mkForce true;
56 };
57 }
58 {
59 # Currently expects an error
60 # mkDefinition doesn't work on option default
61 # This is a limitation and might be resolved in the future
62 options.viaOptionDefault = mkOption {
63 type = lib.types.bool;
64 default = mkDefinition {
65 file = "other";
66 value = true;
67 };
68 };
69 }
70 ];
71}