diff --git a/nixos/doc/manual/release-notes/rl-2411.section.md b/nixos/doc/manual/release-notes/rl-2411.section.md index 5e80d1756601..2db19200de4d 100644 --- a/nixos/doc/manual/release-notes/rl-2411.section.md +++ b/nixos/doc/manual/release-notes/rl-2411.section.md @@ -29,6 +29,8 @@ - [Radicle](https://radicle.xyz), an open source, peer-to-peer code collaboration stack built on Git. Available as [services.radicle](#opt-services.radicle.enable). +- [ddns-updater](https://github.com/qdm12/ddns-updater), a service to update DNS records periodically with WebUI for many DNS providers. Available as [services.ddns-updater](#opt-services.ddns-updater.enable). + - [Renovate](https://github.com/renovatebot/renovate), a dependency updating tool for various git forges and language ecosystems. Available as [services.renovate](#opt-services.renovate.enable). - [wg-access-server](https://github.com/freifunkMUC/wg-access-server/), an all-in-one WireGuard VPN solution with a web ui for connecting devices. Available at [services.wg-access-server](#opt-services.wg-access-server.enable). diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 36e564e3b379..25a930f4a8bb 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -991,6 +991,7 @@ ./services/networking/dante.nix ./services/networking/deconz.nix ./services/networking/ddclient.nix + ./services/networking/ddns-updater.nix ./services/networking/dhcpcd.nix ./services/networking/dnscache.nix ./services/networking/dnscrypt-proxy2.nix diff --git a/nixos/modules/services/networking/ddns-updater.nix b/nixos/modules/services/networking/ddns-updater.nix new file mode 100644 index 000000000000..85daa59fe66d --- /dev/null +++ b/nixos/modules/services/networking/ddns-updater.nix @@ -0,0 +1,46 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.services.ddns-updater; +in +{ + options.services.ddns-updater = { + enable = lib.mkEnableOption "Container to update DNS records periodically with WebUI for many DNS providers"; + + package = lib.mkPackageOption pkgs "ddns-updater" { }; + + environment = lib.mkOption { + type = lib.types.attrsOf lib.types.str; + 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"; + default = { }; + }; + }; + + config = lib.mkIf cfg.enable { + + systemd.services.ddns-updater = { + wantedBy = [ "multi-user.target" ]; + wants = [ "network-online.target" ]; + after = [ "network-online.target" ]; + environment = cfg.environment // { + DATADIR = "%S/ddns-updater"; + }; + unitConfig = { + Description = "DDNS-updater service"; + }; + serviceConfig = { + TimeoutSec = "5min"; + ExecStart = lib.getExe cfg.package; + RestartSec = 30; + DynamicUser = true; + StateDirectory = "ddns-updater"; + Restart = "on-failure"; + }; + }; + }; +} diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index ef4fbce0c331..52450760d991 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -245,6 +245,7 @@ in { davis = handleTest ./davis.nix {}; db-rest = handleTest ./db-rest.nix {}; dconf = handleTest ./dconf.nix {}; + ddns-updater = handleTest ./ddns-updater.nix {}; deconz = handleTest ./deconz.nix {}; deepin = handleTest ./deepin.nix {}; deluge = handleTest ./deluge.nix {}; diff --git a/nixos/tests/ddns-updater.nix b/nixos/tests/ddns-updater.nix new file mode 100644 index 000000000000..caa763e09bba --- /dev/null +++ b/nixos/tests/ddns-updater.nix @@ -0,0 +1,28 @@ +import ./make-test-python.nix ( + { pkgs, lib, ... }: + let + port = 6000; + in + { + name = "ddns-updater"; + + meta.maintainers = with lib.maintainers; [ delliott ]; + + nodes.machine = + { pkgs, ... }: + { + services.ddns-updater = { + enable = true; + environment = { + LISTENING_ADDRESS = ":" + (toString port); + }; + }; + }; + + testScript = '' + machine.wait_for_unit("ddns-updater.service") + machine.wait_for_open_port(${toString port}) + machine.succeed("curl --fail http://localhost:${toString port}/") + ''; + } +) diff --git a/pkgs/by-name/dd/ddns-updater/package.nix b/pkgs/by-name/dd/ddns-updater/package.nix index f4b10e0d6955..8ceaeecd14de 100644 --- a/pkgs/by-name/dd/ddns-updater/package.nix +++ b/pkgs/by-name/dd/ddns-updater/package.nix @@ -1,7 +1,9 @@ { - lib, buildGoModule, fetchFromGitHub, + lib, + nixosTests, + nix-update-script, }: buildGoModule rec { pname = "ddns-updater"; @@ -23,6 +25,13 @@ buildGoModule rec { subPackages = [ "cmd/updater" ]; + passthru = { + tests = { + inherit (nixosTests) ddns-updater; + }; + updateScript = nix-update-script { }; + }; + postInstall = '' mv $out/bin/updater $out/bin/ddns-updater '';