diff --git a/nixos/doc/manual/release-notes/rl-2411.section.md b/nixos/doc/manual/release-notes/rl-2411.section.md index ece3647a4730d..913726f855af1 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 c991a7ec25025..3598e11fe4179 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 0000000000000..3b934e365930f --- /dev/null +++ b/nixos/modules/services/networking/godns.nix @@ -0,0 +1,87 @@ +{ + config, + lib, + pkgs, + ... +}: +let + inherit (lib) + mkEnableOption + mkIf + mkOption + mkPackageOption + types + ; + + cfg = config.services.godns; + + configFormat = pkgs.formats.yaml { }; + configFile = + if cfg.configFile == null then configFormat.generate "config.yaml" cfg.config else cfg.configFile; +in +{ + + options.services.godns = { + enable = mkEnableOption "GoDNS service"; + + package = mkPackageOption pkgs "godns" { }; + + config = mkOption { + type = lib.types.submodule { + freeformType = configFormat.type; + }; + + default = { }; + + description = '' + Configuration for GoDNS. Refer to the [configuration section](1) in the + GoDNS GitHub repository for details. + + [1]: https://github.com/TimothyYe/godns?tab=readme-ov-file#configuration + ''; + }; + + configFile = lib.mkOption { + default = null; + description = '' + Path to a custom GoDNS configuration file. + + If set, this option overrides the configuration provided by the `config` + option. This is particularly useful for specifying sensitive values like + the `login_token` for API providers. For generating a configuration file + with secrets, consider using [sops-nix templates][1]. + + [1]: https://github.com/Mic92/sops-nix?tab=readme-ov-file#templates + ''; + type = types.nullOr types.path; + }; + + additionalRestartTriggers = mkOption { + default = [ ]; + type = types.listOf types.unspecified; + description = '' + Additional triggers to restart the GoDNS service. + + This can be used to restart the service when, for example, a secret used + to generate the configuration changes. + ''; + }; + }; + + config = mkIf cfg.enable { + systemd.services.godns = { + description = "GoDNS service"; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + serviceConfig = { + ExecStart = "${lib.getExe cfg.package} -c ${configFile}"; + Restart = "always"; + KillMode = "process"; + RestartSec = "2s"; + }; + restartTriggers = [ ] ++ cfg.additionalRestartTriggers; + }; + }; + + meta.maintainers = [ lib.maintainers.michaelvanstraten ]; +}