16 cfg = config.services.duckdns;
21 options.services.duckdns = {
26 description = mdDoc ''
27 Enable duckdns service to update dynamic dns of duckdns.
34 description = mdDoc ''
35 The interval at which to run the check and update.
36 See {command}`main 7 systemd.time` for the format.
43 description = mdDoc ''
51 description = mdDoc ''
59 description = mdDoc ''
60 The sub domain name to synchronize. See duckdns url format.
67 description = mdDoc ''
68 The duckdns generated token for account identifying.
74 config = mkIf cfg.enable {
78 assertion = cfg.domain != "";
79 message = "services.duckdns.domain shall not be empty!";
82 assertion = cfg.token != "";
83 message = "services.duckdns.token missing value!";
87 systemd.services.duckdns-updater = {
90 curl = "${pkgs.curl}/bin/curl";
91 get-ipv4-addr = optionalString cfg.ipv4
92 "$(${curl} -s \"https://api.ipify.org\")";
93 get-ipv6-addr = optionalString cfg.ipv6
94 "$(${curl} -s \"https://api6.ipify.org\")";
98 ipv4_addr=${get-ipv4-addr}
99 ipv6_addr=${get-ipv6-addr}
100 ${curl} -s "https://www.duckdns.org/update?domains=${cfg.domain}&token=${cfg.token}&ip=$ipv4_addr&ipv6=$ipv6_addr"
108 systemd.timers.duckdns-updater = {
109 description = "Update duckdns";
110 wantedBy = [ "timers.target" ];
112 OnBootSec = cfg.interval;
113 OnUnitInactiveSec = cfg.interval;
114 Unit = "duckdns-updater.service";