blob: 425b8cb84ca3ff65d4f9754043e05f335bb1dc75 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.services.r53-ddns;
pkg = pkgs.r53-ddns;
in
{
options = {
services.r53-ddns = {
enable = mkEnableOption "r53-ddyns";
interval = mkOption {
type = types.str;
default = "15min";
description = "How often to update the entry";
};
zoneID = mkOption {
type = types.str;
description = "The ID of your zone in Route53";
};
domain = mkOption {
type = types.str;
description = "The name of your domain in Route53";
};
hostname = mkOption {
type = types.str;
description = ''
Manually specify the hostname. Otherwise the tool will try to use the name
returned by the OS (Call to gethostname)
'';
};
ttl = mkOption {
type = types.int;
description = "The TTL for the generated record";
};
environmentFile = mkOption {
type = types.str;
description = ''
File containing the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
in the format of an EnvironmentFile as described by {manpage}`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}"
+ lib.optionalString (cfg.ttl != null) " -ttl ${toString cfg.ttl}";
EnvironmentFile = "${cfg.environmentFile}";
DynamicUser = true;
};
};
};
}
|