2023-11-03 00:11:13 +02:00
|
|
|
{ depot, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
recordType = types.submodule ({ config, name, ... }: {
|
|
|
|
options = {
|
|
|
|
root = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = depot.lib.meta.domain;
|
|
|
|
};
|
|
|
|
consulServicesRoot = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "service.eu-central.sd-magic.${depot.lib.meta.domain}";
|
|
|
|
};
|
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = name;
|
|
|
|
};
|
|
|
|
|
|
|
|
type = mkOption {
|
2023-12-03 02:43:26 +02:00
|
|
|
type = types.enum [ "A" "CNAME" "AAAA" "NS" "MX" "SOA" "TXT" ];
|
2023-11-03 00:11:13 +02:00
|
|
|
default = "A";
|
|
|
|
};
|
|
|
|
target = mkOption {
|
|
|
|
type = with types; listOf str;
|
|
|
|
};
|
|
|
|
ttl = mkOption {
|
|
|
|
type = types.ints.unsigned;
|
|
|
|
default = 86400;
|
|
|
|
};
|
|
|
|
|
|
|
|
consulService = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
|
|
|
};
|
2023-11-03 00:40:43 +02:00
|
|
|
rewrite = {
|
|
|
|
target = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
type = mkOption {
|
|
|
|
type = types.enum [ "exact" "substring" "prefix" "suffix" "regex" ];
|
|
|
|
default = "exact";
|
|
|
|
};
|
2023-11-03 00:11:13 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
config = {
|
2023-11-03 00:40:43 +02:00
|
|
|
rewrite.target = mkIf (config.consulService != null) "${config.consulService}.${config.consulServicesRoot}";
|
2023-11-03 00:11:13 +02:00
|
|
|
};
|
|
|
|
});
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options.dns = {
|
|
|
|
records = mkOption {
|
|
|
|
type = with types; attrsOf recordType;
|
|
|
|
default = {};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|