Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ddns-updater: Add module and update script #304624

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2411.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 46 additions & 0 deletions nixos/modules/services/networking/ddns-updater.nix
Original file line number Diff line number Diff line change
@@ -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" ];
delliottxyz marked this conversation as resolved.
Show resolved Hide resolved
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";
};
};
};
}
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
Expand Down
28 changes: 28 additions & 0 deletions nixos/tests/ddns-updater.nix
Original file line number Diff line number Diff line change
@@ -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}/")
'';
}
)
17 changes: 13 additions & 4 deletions pkgs/by-name/dd/ddns-updater/package.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
{
lib,
buildGoModule,
fetchFromGitHub,
lib,
nixosTests,
nix-update-script,
}:
buildGoModule rec {
pname = "ddns-updater";
version = "2.6.0";
version = "2.7.0";

src = fetchFromGitHub {
owner = "qdm12";
repo = "ddns-updater";
rev = "v${version}";
hash = "sha256-NU6KXVjggsXVCKImGqbB1AXcph+ycRfkk5S4JNq0cHg=";
hash = "sha256-U8Vw7dsj/efqvpooT3QQjNp41AuGYJ/Gz/pA8Em3diE=";
};

vendorHash = "sha256-Ibrv0m3Tz/5JbkHYmiJ9Ijo37fjHc7TP100K7ZTwO8I=";
vendorHash = "sha256-M9Al3zl2Ltv4yWdyRB3+9zpTr3foliu5WweImHltz3M=";

ldflags = [
"-s"
Expand All @@ -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
'';
Expand Down