-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
f8c6116
commit 9b368a5
Showing
3 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ]; | ||
} |