mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
Depot cannot be stopped and neither can I
This commit is contained in:
parent
1f613c6fb7
commit
01460123a6
256 changed files with 15 additions and 15 deletions
65
depot/modules/nixos/dns.nix
Normal file
65
depot/modules/nixos/dns.nix
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
{ config, lib, tf, ... }:
|
||||
|
||||
/*
|
||||
This module:
|
||||
* Provides options for setting the domain/tld/... used by default in my service configs.
|
||||
*/
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
options.kw.dns = {
|
||||
email = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = "";
|
||||
};
|
||||
tld = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = "";
|
||||
};
|
||||
domain = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = "";
|
||||
};
|
||||
ygg_prefix = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = "";
|
||||
};
|
||||
isPublic = mkEnableOption "Provide DNS for the public primary IP addresses of the host";
|
||||
ipv4 = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
};
|
||||
ipv6 = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
# Set these.
|
||||
kw.dns.email = mkDefault "kat@kittywit.ch";
|
||||
kw.dns.tld = mkDefault "kittywit.ch.";
|
||||
kw.dns.ygg_prefix = mkDefault "net";
|
||||
|
||||
# This should be set in host config if it needs to be set for a host. Otherwise, they're retrieved from terraform.
|
||||
kw.dns.ipv4 = mkDefault (mkIf (tf.resources ? config.networking.hostName) (mkOptionDefault (config.deploy.tf.resources."${config.networking.hostName}".refAttr "ipv4_address")));
|
||||
kw.dns.ipv6 = mkDefault (mkIf (tf.resources ? config.networking.hostName) (mkOptionDefault (config.deploy.tf.resources."${config.networking.hostName}".refAttr "ipv6_address")));
|
||||
|
||||
# These are derived.
|
||||
kw.dns.domain = builtins.substring 0 ((builtins.stringLength config.kw.dns.tld) - 1) config.kw.dns.tld;
|
||||
|
||||
deploy.tf.dns.records = lib.mkIf (config.kw.dns.isPublic) {
|
||||
"node_${config.networking.hostName}_v4" = {
|
||||
tld = config.kw.dns.tld;
|
||||
domain = config.networking.hostName;
|
||||
a.address = config.kw.dns.ipv4;
|
||||
};
|
||||
"node_${config.networking.hostName}_v6" = {
|
||||
tld = config.kw.dns.tld;
|
||||
domain = config.networking.hostName;
|
||||
aaaa.address = config.kw.dns.ipv6;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue