at 25.11-pre 1.2 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8let 9 cfg = config.services.ddns-updater; 10in 11{ 12 options.services.ddns-updater = { 13 enable = lib.mkEnableOption "Container to update DNS records periodically with WebUI for many DNS providers"; 14 15 package = lib.mkPackageOption pkgs "ddns-updater" { }; 16 17 environment = lib.mkOption { 18 type = lib.types.attrsOf lib.types.str; 19 description = "Environment variables to be set for the ddns-updater service. DATADIR is ignored to enable using systemd DynamicUser. For full list see <https://github.com/qdm12/ddns-updater>"; 20 default = { }; 21 }; 22 }; 23 24 config = lib.mkIf cfg.enable { 25 26 systemd.services.ddns-updater = { 27 wantedBy = [ "multi-user.target" ]; 28 wants = [ "network-online.target" ]; 29 after = [ "network-online.target" ]; 30 environment = cfg.environment // { 31 DATADIR = "%S/ddns-updater"; 32 }; 33 unitConfig = { 34 Description = "DDNS-updater service"; 35 }; 36 serviceConfig = { 37 TimeoutSec = "5min"; 38 ExecStart = lib.getExe cfg.package; 39 RestartSec = 30; 40 DynamicUser = true; 41 StateDirectory = "ddns-updater"; 42 Restart = "on-failure"; 43 }; 44 }; 45 }; 46}