nix/container/Ddns.nix

55 lines
1.1 KiB
Nix
Raw Normal View History

2024-06-25 04:04:39 +03:00
{ container, lib, config, ... } @args: with lib; let
cfg = config.container.module.ddns;
2024-06-09 23:35:53 +03:00
in {
2024-06-25 04:04:39 +03:00
options = {
container.module.ddns = {
enable = mkEnableOption "Dynamic dns client.";
address = mkOption {
default = "10.1.0.31";
type = types.str;
};
storage = mkOption {
default = "${config.container.storage}/ddns";
type = types.str;
2024-06-09 23:35:53 +03:00
};
};
2024-06-25 04:04:39 +03:00
};
config = mkIf cfg.enable {
systemd.tmpfiles.rules = container.mkContainerDir cfg [
"data"
];
containers.ddns = container.mkContainer cfg {
bindMounts = {
"/data" = {
hostPath = "${cfg.storage}/data";
isReadOnly = true;
};
};
2024-06-09 23:35:53 +03:00
2024-06-25 04:04:39 +03:00
config = { ... }: container.mkContainerConfig cfg {
services.cloudflare-dyndns = {
enable = true;
apiTokenFile = "/data/token";
2024-08-31 19:15:32 +03:00
deleteMissing = false;
2024-06-25 04:04:39 +03:00
ipv4 = true;
ipv6 = false;
proxied = false;
domains = let
domain = config.container.domain;
in [ domain ] ++ map (sub: "${sub}.${domain}") [
2024-06-25 04:04:39 +03:00
"cloud"
"git"
"mail"
"office"
"paste"
"play"
"vpn"
];
};
2024-06-09 23:35:53 +03:00
};
};
};
}