2022-06-16 17:23:12 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.r53-ddns;
|
|
|
|
pkg = pkgs.r53-ddns;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.r53-ddns = {
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
enable = mkEnableOption "r53-ddyns";
|
2022-06-16 17:23:12 +00:00
|
|
|
|
|
|
|
interval = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "15min";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "How often to update the entry";
|
2022-06-16 17:23:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
zoneID = mkOption {
|
|
|
|
type = types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "The ID of your zone in Route53";
|
2022-06-16 17:23:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
domain = mkOption {
|
|
|
|
type = types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "The name of your domain in Route53";
|
2022-06-16 17:23:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
hostname = mkOption {
|
|
|
|
type = types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-06-16 17:23:12 +00:00
|
|
|
Manually specify the hostname. Otherwise the tool will try to use the name
|
|
|
|
returned by the OS (Call to gethostname)
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
environmentFile = mkOption {
|
|
|
|
type = types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-06-16 17:23:12 +00:00
|
|
|
File containing the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
|
|
|
|
in the format of an EnvironmentFile as described by systemd.exec(5)
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
systemd.timers.r53-ddns = {
|
|
|
|
description = "r53-ddns timer";
|
|
|
|
wantedBy = [ "timers.target" ];
|
|
|
|
timerConfig = {
|
|
|
|
OnBootSec = cfg.interval;
|
|
|
|
OnUnitActiveSec = cfg.interval;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.r53-ddns = {
|
|
|
|
description = "r53-ddns service";
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkg}/bin/r53-ddns -zone-id ${cfg.zoneID} -domain ${cfg.domain}"
|
|
|
|
+ lib.optionalString (cfg.hostname != null) " -hostname ${cfg.hostname}";
|
|
|
|
EnvironmentFile = "${cfg.environmentFile}";
|
|
|
|
DynamicUser = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|