1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7
8with lib;
9
10let
11 cfg = config.services.r53-ddns;
12 pkg = pkgs.r53-ddns;
13in
14{
15 options = {
16 services.r53-ddns = {
17
18 enable = mkEnableOption "r53-ddyns";
19
20 interval = mkOption {
21 type = types.str;
22 default = "15min";
23 description = "How often to update the entry";
24 };
25
26 zoneID = mkOption {
27 type = types.str;
28 description = "The ID of your zone in Route53";
29 };
30
31 domain = mkOption {
32 type = types.str;
33 description = "The name of your domain in Route53";
34 };
35
36 hostname = mkOption {
37 type = types.str;
38 description = ''
39 Manually specify the hostname. Otherwise the tool will try to use the name
40 returned by the OS (Call to gethostname)
41 '';
42 };
43
44 environmentFile = mkOption {
45 type = types.str;
46 description = ''
47 File containing the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
48 in the format of an EnvironmentFile as described by {manpage}`systemd.exec(5)`
49 '';
50 };
51
52 };
53 };
54
55 config = mkIf cfg.enable {
56
57 systemd.timers.r53-ddns = {
58 description = "r53-ddns timer";
59 wantedBy = [ "timers.target" ];
60 timerConfig = {
61 OnBootSec = cfg.interval;
62 OnUnitActiveSec = cfg.interval;
63 };
64 };
65
66 systemd.services.r53-ddns = {
67 description = "r53-ddns service";
68 serviceConfig = {
69 ExecStart =
70 "${pkg}/bin/r53-ddns -zone-id ${cfg.zoneID} -domain ${cfg.domain}"
71 + lib.optionalString (cfg.hostname != null) " -hostname ${cfg.hostname}";
72 EnvironmentFile = "${cfg.environmentFile}";
73 DynamicUser = true;
74 };
75 };
76
77 };
78}