11 cfg = config.services.powerdns;
12 configDir = pkgs.writeTextDir "pdns.conf" "${cfg.extraConfig}";
13 finalConfigDir = if cfg.secretFile == null then configDir else "/run/pdns";
18 enable = mkEnableOption "PowerDNS domain name server";
20 extraConfig = mkOption {
22 default = "launch=bind";
24 PowerDNS configuration. Refer to
25 <https://doc.powerdns.com/authoritative/settings.html>
26 for details on supported values.
30 secretFile = mkOption {
31 type = types.nullOr types.path;
33 example = "/run/keys/powerdns.env";
35 Environment variables from this file will be interpolated into the
36 final config file using envsubst with this syntax: `$ENVIRONMENT`
38 The file should contain lines formatted as `SECRET_VAR=SECRET_VALUE`.
39 This is useful to avoid putting secrets into the nix store.
45 config = mkIf cfg.enable {
47 environment.etc.pdns.source = finalConfigDir;
49 systemd.packages = [ pkgs.pdns ];
51 systemd.services.pdns = {
52 wantedBy = [ "multi-user.target" ];
61 EnvironmentFile = lib.optional (cfg.secretFile != null) cfg.secretFile;
62 ExecStartPre = lib.optional (cfg.secretFile != null) (
63 pkgs.writeShellScript "pdns-pre-start" ''
65 ${pkgs.envsubst}/bin/envsubst -i "${configDir}/pdns.conf" > ${finalConfigDir}/pdns.conf
70 "${pkgs.pdns}/bin/pdns_server --config-dir=${finalConfigDir} --guardian=no --daemon=no --disable-syslog --log-timestamp=no --write-pid=no"
78 description = "PowerDNS";
81 users.groups.pdns = { };