Skip to content

Commit a890891

Browse files
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.
1 parent 015448e commit a890891

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

nixos/doc/manual/release-notes/rl-2505.section.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@
214214
- [ipfs-cluster](https://ipfscluster.io/), Pinset orchestration for IPFS. Available as [services.ipfs-cluster](#opt-services.ipfs-cluster.enable)
215215

216216
- [bitbox-bridge](https://github.com/BitBoxSwiss/bitbox-bridge), a bridge software that connects BitBox hardware wallets to computers & web wallets like [Rabby](https://rabby.io/). Allows one to interact & transact with smart contracts, Web3 websites & financial services without storing private keys anywhere other than the hardware wallet. Available as [services.bitbox-bridge](#opt-services.bitbox-bridge.enable).
217+
218+
- [GoDNS](https://github.com/TimothyYe/godns), a dynamic DNS client written in Go, which supports multiple DNS providers. Available as [services.godns](option.html#opt-services.godns.enable).
219+
217220
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
218221

219222
## Backward Incompatibilities {#sec-release-25.05-incompatibilities}

nixos/modules/module-list.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,7 @@
11371137
./services/networking/go-shadowsocks2.nix
11381138
./services/networking/gobgpd.nix
11391139
./services/networking/gokapi.nix
1140+
./services/networking/godns.nix
11401141
./services/networking/gvpe.nix
11411142
./services/networking/hans.nix
11421143
./services/networking/harmonia.nix
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}:
7+
let
8+
inherit (lib)
9+
mkEnableOption
10+
mkIf
11+
mkOption
12+
mkPackageOption
13+
types
14+
;
15+
16+
cfg = config.services.godns;
17+
18+
settingsFormat = pkgs.formats.yaml { };
19+
in
20+
{
21+
options.services.godns = {
22+
enable = mkEnableOption "GoDNS service";
23+
24+
package = mkPackageOption pkgs "godns" { };
25+
26+
settings = mkOption {
27+
type = types.submodule {
28+
freeformType = settingsFormat.type;
29+
};
30+
31+
description = ''
32+
Configuration for GoDNS. Refer to the [configuration section](1) in the
33+
GoDNS GitHub repository for details.
34+
35+
[1]: https://github.com/TimothyYe/godns?tab=readme-ov-file#configuration
36+
'';
37+
38+
example = {
39+
provider = "Cloudflare";
40+
login_token_file = "$CREDENTIALS_DIRECTORY/login_token";
41+
domains = [
42+
{
43+
domain_name = "example.com";
44+
sub_domains = [ "foo" ];
45+
}
46+
];
47+
ipv6_urls = [
48+
"https://api6.ipify.org"
49+
"https://ip2location.io/ip"
50+
"https://v6.ipinfo.io/ip"
51+
];
52+
ip_type = "IPv6";
53+
interval = 300;
54+
};
55+
};
56+
57+
loadCredential = lib.mkOption {
58+
type = types.listOf types.str;
59+
default = [ ];
60+
example = [ "login_token:/path/to/login_token" ];
61+
description = ''
62+
This can be used to pass secrets to the systemd service without adding
63+
them to the nix store.
64+
'';
65+
};
66+
};
67+
68+
config = mkIf cfg.enable {
69+
systemd.services.godns = {
70+
description = "GoDNS service";
71+
wantedBy = [ "multi-user.target" ];
72+
after = [ "network.target" ];
73+
serviceConfig = {
74+
DynamicUser = true;
75+
ExecStart = "${lib.getExe cfg.package} -c ${settingsFormat.generate "config.yaml" cfg.settings}";
76+
LoadCredential = cfg.loadCredential;
77+
Restart = "always";
78+
RestartSec = "2s";
79+
};
80+
};
81+
};
82+
83+
meta.maintainers = [ lib.maintainers.michaelvanstraten ];
84+
}

0 commit comments

Comments
 (0)