greenhouse

kore

my public infrastructure monorepo

git clone [email protected]:kore.git

kore / nixos / features / kore.nix40 lines · 914B · 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 = [ "workstation" ];
35        };
36      };
37      currentHost = config.kore.hosts.${config.networking.hostName};
38    };
39  };
40}