mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-27 09:23:01 +00:00
6afb255d97
these changes were generated with nixq 0.0.2, by running nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix two mentions of the mdDoc function remain in nixos/, both of which are inside of comments. Since lib.mdDoc is already defined as just id, this commit is a no-op as far as Nix (and the built manual) is concerned.
70 lines
2.1 KiB
Nix
70 lines
2.1 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.powerdns;
|
|
configDir = pkgs.writeTextDir "pdns.conf" "${cfg.extraConfig}";
|
|
finalConfigDir = if cfg.secretFile == null then configDir else "/run/pdns";
|
|
in {
|
|
options = {
|
|
services.powerdns = {
|
|
enable = mkEnableOption "PowerDNS domain name server";
|
|
|
|
extraConfig = mkOption {
|
|
type = types.lines;
|
|
default = "launch=bind";
|
|
description = ''
|
|
PowerDNS configuration. Refer to
|
|
<https://doc.powerdns.com/authoritative/settings.html>
|
|
for details on supported values.
|
|
'';
|
|
};
|
|
|
|
secretFile = mkOption {
|
|
type = types.nullOr types.path;
|
|
default = null;
|
|
example = "/run/keys/powerdns.env";
|
|
description = ''
|
|
Environment variables from this file will be interpolated into the
|
|
final config file using envsubst with this syntax: `$ENVIRONMENT`
|
|
or `''${VARIABLE}`.
|
|
The file should contain lines formatted as `SECRET_VAR=SECRET_VALUE`.
|
|
This is useful to avoid putting secrets into the nix store.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.etc.pdns.source = finalConfigDir;
|
|
|
|
systemd.packages = [ pkgs.pdns ];
|
|
|
|
systemd.services.pdns = {
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [ "network.target" "mysql.service" "postgresql.service" "openldap.service" ];
|
|
|
|
serviceConfig = {
|
|
EnvironmentFile = lib.optional (cfg.secretFile != null) cfg.secretFile;
|
|
ExecStartPre = lib.optional (cfg.secretFile != null)
|
|
(pkgs.writeShellScript "pdns-pre-start" ''
|
|
umask 077
|
|
${pkgs.envsubst}/bin/envsubst -i "${configDir}/pdns.conf" > ${finalConfigDir}/pdns.conf
|
|
'');
|
|
ExecStart = [ "" "${pkgs.pdns}/bin/pdns_server --config-dir=${finalConfigDir} --guardian=no --daemon=no --disable-syslog --log-timestamp=no --write-pid=no" ];
|
|
};
|
|
};
|
|
|
|
users.users.pdns = {
|
|
isSystemUser = true;
|
|
group = "pdns";
|
|
description = "PowerDNS";
|
|
};
|
|
|
|
users.groups.pdns = {};
|
|
|
|
};
|
|
}
|