Skip to content

Commit

Permalink
nixos/hickory-dns: expose configFile as a toplevel option
Browse files Browse the repository at this point in the history
this allows users the option to configure hickory-dns manually,
for example from the .toml files specified in hickory-dns examples
directory.
  • Loading branch information
uninsane committed Dec 8, 2024
1 parent 3715bf4 commit 9117dd6
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions nixos/modules/services/networking/hickory-dns.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ let
cfg = config.services.hickory-dns;
toml = pkgs.formats.toml { };

configFile = toml.generate "hickory-dns.toml" (
lib.filterAttrsRecursive (_: v: v != null) cfg.settings
);

zoneType = lib.types.submodule ({ config, ... }: {
freeformType = toml.type;
options = with lib; {
Expand Down Expand Up @@ -83,6 +79,22 @@ in
If neither `quiet` nor `debug` are enabled, logging defaults to the INFO level.
'';
};
configFile = mkOption {
type = types.path;
default = toml.generate "hickory-dns.toml" (
lib.filterAttrsRecursive (_: v: v != null) cfg.settings
);
defaultText = lib.literalExpression ''
let toml = pkgs.formats.toml { }; in toml.generate "hickory-dns.toml" cfg.settings
'';
description = ''
Path to an existing toml file to configure hickory-dns with.
This can usually be left unspecified, in which case it will be
generated from the values in `settings`.
If manually specified, then the options in `settings` are ignored.
'';
};
settings = mkOption {
description = ''
Settings for hickory-dns. The options enumerated here are not exhaustive.
Expand Down Expand Up @@ -143,7 +155,7 @@ in
flags = (lib.optional cfg.debug "--debug") ++ (lib.optional cfg.quiet "--quiet");
flagsStr = builtins.concatStringsSep " " flags;
in ''
${lib.getExe cfg.package} --config ${configFile} ${flagsStr}
${lib.getExe cfg.package} --config ${cfg.configFile} ${flagsStr}
'';
Type = "simple";
Restart = "on-failure";
Expand Down

0 comments on commit 9117dd6

Please sign in to comment.