Depot cannot be stopped and neither can I

This commit is contained in:
kat witch 2021-08-09 02:41:43 +01:00
parent 1f613c6fb7
commit 01460123a6
No known key found for this signature in database
GPG key ID: 1B477797DCA5EC72
256 changed files with 15 additions and 15 deletions

View 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;
};
};
};
}