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