at 25.11-pre 1.5 kB view raw
1{ lib, ... }: 2let 3 inherit (lib) types mkOption setDefaultModuleLocation; 4 inherit (types) 5 deferredModule 6 lazyAttrsOf 7 submodule 8 str 9 raw 10 enum 11 ; 12in 13{ 14 imports = [ 15 # generic module, declaring submodules: 16 # - nodes.<name> 17 # - default 18 # where all nodes include the default 19 ( 20 { config, ... }: 21 { 22 _file = "generic.nix"; 23 options.nodes = mkOption { 24 type = lazyAttrsOf (submodule { 25 imports = [ config.default ]; 26 }); 27 default = { }; 28 }; 29 options.default = mkOption { 30 type = deferredModule; 31 default = { }; 32 description = '' 33 Module that is included in all nodes. 34 ''; 35 }; 36 } 37 ) 38 39 { 40 _file = "default-1.nix"; 41 default = 42 { config, ... }: 43 { 44 options.settingsDict = lib.mkOption { 45 type = lazyAttrsOf str; 46 default = { }; 47 }; 48 options.bottom = lib.mkOption { type = enum [ ]; }; 49 }; 50 } 51 52 { 53 _file = "default-a-is-b.nix"; 54 default = ./define-settingsDict-a-is-b.nix; 55 } 56 57 { 58 _file = "nodes-foo.nix"; 59 nodes.foo.settingsDict.b = "beta"; 60 } 61 62 { 63 _file = "the-file-that-contains-the-bad-config.nix"; 64 default.bottom = "bogus"; 65 } 66 67 { 68 _file = "nodes-foo-c-is-a.nix"; 69 nodes.foo = 70 { config, ... }: 71 { 72 settingsDict.c = config.settingsDict.a; 73 }; 74 } 75 76 ]; 77}