raito-shared-public-infra/modules/hosts.nix

48 lines
1.3 KiB
Nix
Raw Normal View History

{ lib, config, ... }:
let
hostOptions = with lib; {
ipv4 = mkOption {
default = null;
type = types.nullOr types.str;
description = ''
own ipv4 address
'';
};
ipv6 = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
own ipv6 address
'';
};
};
in
{
options = with lib; {
networking.newtype.hosts = mkOption {
type = with types; attrsOf (submodule [{ options = hostOptions; }]);
description = "A host in our cluster";
};
networking.newtype.currentHost = mkOption {
type = with types; submodule [{ options = hostOptions; }];
default = config.networking.newtype.hosts.${config.networking.hostName};
description = "The host that is described by this configuration";
};
};
config = {
warnings =
lib.optional (!(config.networking.newtype.hosts ? ${config.networking.hostName}) &&
config.networking.hostName != "nixos" # we dont care about nixos netboot/installer images
)
"Please add network configuration for ${config.networking.hostName}. None found in ${./hosts.nix}";
# usually, for each host there is a hostname.dse.in.tum.de and hostname.r domain
networking.newtype.hosts = {
epyc = {
ipv6 = "2001:470:ca5e:dee:587c:7a50:f36c:cae8";
};
};
};
}