kore / nixos / features / kore.nix44 lines · 1012B · raw
1{ config, lib, ... }:
2
3let
4 hostOptions = with lib; {
5 ipv4 = mkOption {
6 type = types.str;
7 default = null;
8 };
9 roles = mkOption {
10 type = types.nullOr (types.listOf types.str);
11 default = null;
12 };
13 };
14in {
15 options.kore = with lib; {
16 hosts = mkOption {
17 type = types.attrsOf (types.submodule [{ options = hostOptions; }]);
18 default = null;
19 };
20 currentHost = mkOption {
21 type = types.submodule [{ options = hostOptions; }];
22 default = null;
23 };
24 };
25 config = {
26 warnings = lib.optional (!(config.kore.hosts ? ${config.networking.hostName}))
27 "no configuration for ${config.networking.hostName} found";
28
29 # TMP
30 kore = {
31 hosts = {
32 sunflower = {
33 ipv4 = "0.0.0.0";
34 roles = [ "home" "workstation" ];
35 };
36 gomphrena = {
37 ipv4 = "0.0.0.0";
38 roles = [ "home" ];
39 };
40 };
41 currentHost = config.kore.hosts.${config.networking.hostName};
42 };
43 };
44}