nixpkgs/nixos/modules/services/networking/pdnsd.nix
pennae ef176dcf7e nixos/*: automatically convert option descriptions
conversions were done using https://github.com/pennae/nix-doc-munge
using (probably) rev f34e145 running

    nix-doc-munge nixos/**/*.nix
    nix-doc-munge --import nixos/**/*.nix

the tool ensures that only changes that could affect the generated
manual *but don't* are committed, other changes require manual review
and are discarded.
2022-08-31 16:32:53 +02:00

92 lines
2.2 KiB
Nix

{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.services.pdnsd;
pdnsd = pkgs.pdnsd;
pdnsdUser = "pdnsd";
pdnsdGroup = "pdnsd";
pdnsdConf = pkgs.writeText "pdnsd.conf"
''
global {
run_as=${pdnsdUser};
cache_dir="${cfg.cacheDir}";
${cfg.globalConfig}
}
server {
${cfg.serverConfig}
}
${cfg.extraConfig}
'';
in
{ options =
{ services.pdnsd =
{ enable = mkEnableOption (lib.mdDoc "pdnsd");
cacheDir = mkOption {
type = types.str;
default = "/var/cache/pdnsd";
description = lib.mdDoc "Directory holding the pdnsd cache";
};
globalConfig = mkOption {
type = types.lines;
default = "";
description = lib.mdDoc ''
Global configuration that should be added to the global directory
of `pdnsd.conf`.
'';
};
serverConfig = mkOption {
type = types.lines;
default = "";
description = lib.mdDoc ''
Server configuration that should be added to the server directory
of `pdnsd.conf`.
'';
};
extraConfig = mkOption {
type = types.lines;
default = "";
description = lib.mdDoc ''
Extra configuration directives that should be added to
`pdnsd.conf`.
'';
};
};
};
config = mkIf cfg.enable {
users.users.${pdnsdUser} = {
uid = config.ids.uids.pdnsd;
group = pdnsdGroup;
description = "pdnsd user";
};
users.groups.${pdnsdGroup} = {
gid = config.ids.gids.pdnsd;
};
systemd.services.pdnsd =
{ wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
preStart =
''
mkdir -p "${cfg.cacheDir}"
touch "${cfg.cacheDir}/pdnsd.cache"
chown -R ${pdnsdUser}:${pdnsdGroup} "${cfg.cacheDir}"
'';
description = "pdnsd";
serviceConfig =
{
ExecStart = "${pdnsd}/bin/pdnsd -c ${pdnsdConf}";
};
};
};
}