1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-25 03:17:13 +00:00
nixpkgs/nixos/modules/services/networking/dnsdist.nix

54 lines
1.3 KiB
Nix
Raw Normal View History

2018-03-17 23:05:27 +00:00
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.dnsdist;
configFile = pkgs.writeText "dnsdist.conf" ''
2018-03-17 23:05:27 +00:00
setLocal('${cfg.listenAddress}:${toString cfg.listenPort}')
${cfg.extraConfig}
'';
2018-03-17 23:05:27 +00:00
in {
options = {
services.dnsdist = {
enable = mkEnableOption "dnsdist domain name server";
listenAddress = mkOption {
type = types.str;
description = "Listen IP Address";
default = "0.0.0.0";
};
listenPort = mkOption {
type = types.int;
description = "Listen port";
default = 53;
};
extraConfig = mkOption {
type = types.lines;
default = "";
2018-03-17 23:05:27 +00:00
description = ''
Extra lines to be added verbatim to dnsdist.conf.
'';
};
};
};
config = mkIf cfg.enable {
systemd.packages = [ pkgs.dnsdist ];
2018-03-17 23:05:27 +00:00
systemd.services.dnsdist = {
wantedBy = [ "multi-user.target" ];
startLimitIntervalSec = 0;
2018-03-17 23:05:27 +00:00
serviceConfig = {
DynamicUser = true;
# upstream overrides for better nixos compatibility
ExecStartPre = [ "" "${pkgs.dnsdist}/bin/dnsdist --check-config --config ${configFile}" ];
ExecStart = [ "" "${pkgs.dnsdist}/bin/dnsdist --supervised --disable-syslog --config ${configFile}" ];
2018-03-17 23:05:27 +00:00
};
};
};
}