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