2022-03-10 21:45:41 +00:00
|
|
|
{ lib, ... }:
|
|
|
|
let
|
|
|
|
inherit (lib) types mkOption setDefaultModuleLocation;
|
2022-05-18 16:42:18 +00:00
|
|
|
inherit (types) deferredModule lazyAttrsOf submodule str raw enum;
|
2022-03-10 21:45:41 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
# generic module, declaring submodules:
|
|
|
|
# - nodes.<name>
|
|
|
|
# - default
|
|
|
|
# where all nodes include the default
|
|
|
|
({ config, ... }: {
|
|
|
|
_file = "generic.nix";
|
|
|
|
options.nodes = mkOption {
|
|
|
|
type = lazyAttrsOf (submodule { imports = config.default; });
|
|
|
|
default = {};
|
|
|
|
};
|
|
|
|
options.default = mkOption {
|
|
|
|
type = deferredModule;
|
|
|
|
default = { };
|
|
|
|
description = ''
|
|
|
|
Module that is included in all nodes.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
})
|
|
|
|
|
|
|
|
{
|
|
|
|
_file = "default-1.nix";
|
|
|
|
default = { config, ... }: {
|
|
|
|
options.settingsDict = lib.mkOption { type = lazyAttrsOf str; default = {}; };
|
2022-05-18 16:42:18 +00:00
|
|
|
options.bottom = lib.mkOption { type = enum []; };
|
2022-03-10 21:45:41 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
_file = "default-a-is-b.nix";
|
|
|
|
default = { config, ... }: {
|
|
|
|
settingsDict.a = config.settingsDict.b;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
_file = "nodes-foo.nix";
|
|
|
|
nodes.foo.settingsDict.b = "beta";
|
|
|
|
}
|
|
|
|
|
2022-05-18 16:42:18 +00:00
|
|
|
{
|
|
|
|
_file = "the-file-that-contains-the-bad-config.nix";
|
|
|
|
default.bottom = "bogus";
|
|
|
|
}
|
|
|
|
|
2022-03-10 21:45:41 +00:00
|
|
|
{
|
|
|
|
_file = "nodes-foo-c-is-a.nix";
|
|
|
|
nodes.foo = { config, ... }: {
|
|
|
|
settingsDict.c = config.settingsDict.a;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
];
|
|
|
|
}
|