From 54f25d0582825e3d3bf6b681461e749be8e16413 Mon Sep 17 00:00:00 2001 From: Michael van Straten Date: Sun, 13 Oct 2024 17:01:46 +0200 Subject: [PATCH] nixos/godns: init module Initial implementation of the GoDNS service module. This module allows users to enable and configure the GoDNS service on their NixOS system. It includes options for specifying the GoDNS package and the path to the configuration file. --- .../manual/release-notes/rl-2411.section.md | 2 + nixos/modules/module-list.nix | 1 + nixos/modules/services/networking/godns.nix | 56 +++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 nixos/modules/services/networking/godns.nix diff --git a/nixos/doc/manual/release-notes/rl-2411.section.md b/nixos/doc/manual/release-notes/rl-2411.section.md index ece3647a4730d7..913726f855af11 100644 --- a/nixos/doc/manual/release-notes/rl-2411.section.md +++ b/nixos/doc/manual/release-notes/rl-2411.section.md @@ -207,6 +207,8 @@ - [Glances](https://github.com/nicolargo/glances), an open-source system cross-platform monitoring tool. Available as [services.glances](option.html#opt-services.glances). +- [GoDNS](https://github.com/TimothyYe/godns), a dynamic DNS client written in Go, which supports multiple DNS providers. Available as [services.godns](#opt-services.godns.enable). + ## Backward Incompatibilities {#sec-release-24.11-incompatibilities} - Nixpkgs now requires Nix 2.3.17 or newer to allow for zstd compressed binary artifacts. diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index c991a7ec25025d..3598e11fe41797 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -1064,6 +1064,7 @@ ./services/networking/go-neb.nix ./services/networking/go-shadowsocks2.nix ./services/networking/gobgpd.nix + ./services/networking/godns.nix ./services/networking/gvpe.nix ./services/networking/hans.nix ./services/networking/harmonia.nix diff --git a/nixos/modules/services/networking/godns.nix b/nixos/modules/services/networking/godns.nix new file mode 100644 index 00000000000000..15e1318a7dbe66 --- /dev/null +++ b/nixos/modules/services/networking/godns.nix @@ -0,0 +1,56 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.services.godns; + + inherit (lib) + mkEnableOption + mkIf + mkOption + mkPackageOption + types + ; +in +{ + + options.services.godns = { + enable = mkEnableOption "GoDNS Service"; + + package = mkPackageOption pkgs "godns" { }; + + configPath = mkOption { + type = types.path; + description = "Path to the configuration file for godns."; + example = "/etc/godns/config.json"; + }; + + additionalRestartTriggers = mkOption { + default = [ ]; + type = types.listOf types.unspecified; + description = '' + These are additional restart triggers that are passed to the systemd service. + ''; + }; + }; + + config = mkIf cfg.enable { + systemd.services.godns = { + description = "GoDNS Service"; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + serviceConfig = { + ExecStart = "${lib.getExe cfg.package} -c ${cfg.configPath}"; + Restart = "always"; + KillMode = "process"; + RestartSec = "2s"; + }; + restartTriggers = [ ] ++ cfg.additionalRestartTriggers; + }; + }; + + meta.maintainers = [ lib.maintainers.michaelvanstraten ]; +}