git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #100892 from aanderse/pdns-recursor

nixos/pdns-recursor: use upstream systemd unit

commit5265d49a36bb5a18c85e6817b338b456acc3b8cc authorAaron Andersen <aaron@fosslib.net> dateSun 18 Oct 2020, 20:13 (6 years ago) parent713c368dc790c1
4 files changed+21−33
nixos/doc/manual/release-notes/rl-2103.xml+6 nixos/modules/misc/ids.nix+1−1 nixos/modules/services/networking/pdns-recursor.nix+13−31 pkgs/servers/dns/pdns-recursor/default.nix+1−1
nixos/doc/manual/release-notes/rl-2103.xml+6
@@ -93,6 +93,12 @@
9393 <literal>kicad/default.nix</literal>.
9494 </para>
9595 </listitem>
96+ <listitem>
97+ <para>
98+ The socket for the <literal>pdns-recursor</literal> module was moved from <literal>/var/lib/pdns-recursor</literal>
99+ to <literal>/run/pdns-recursor</literal> to match upstream.
100+ </para>
101+ </listitem>
96102 </itemizedlist>
97103 </section>
98104
nixos/modules/misc/ids.nix+1−1
@@ -297,7 +297,7 @@ in
297297 headphones = 266;
298298 couchpotato = 267;
299299 gogs = 268;
300− pdns-recursor = 269;
300+ #pdns-recursor = 269; # dynamically allocated as of 2020-20-18
301301 #kresd = 270; # switched to "knot-resolver" with dynamic ID
302302 rpc = 271;
303303 geoip = 272;
nixos/modules/services/networking/pdns-recursor.nix+13−31
@@ -3,9 +3,6 @@
33with lib;
44
55let
6− dataDir = "/var/lib/pdns-recursor";
7− username = "pdns-recursor";
8−
96 cfg = config.services.pdns-recursor;
107
118 oneOrMore = type: with types; either type (listOf type);
@@ -21,7 +18,7 @@ let
2118 else if builtins.isList val then (concatMapStringsSep "," serialize val)
2219 else "";
2320
24− configFile = pkgs.writeText "recursor.conf"
21+ configDir = pkgs.writeTextDir "recursor.conf"
2522 (concatStringsSep "\n"
2623 (flip mapAttrsToList cfg.settings
2724 (name: val: "${name}=${serialize val}")));
@@ -173,45 +170,30 @@ in {
173170 serve-rfc1918 = cfg.serveRFC1918;
174171 lua-config-file = pkgs.writeText "recursor.lua" cfg.luaConfig;
175172
173+ daemon = false;
174+ write-pid = false;
176175 log-timestamp = false;
177176 disable-syslog = true;
178177 };
179178
180− users.users.${username} = {
181− home = dataDir;
182− createHome = true;
183− uid = config.ids.uids.pdns-recursor;
184− description = "PowerDNS Recursor daemon user";
185− };
179+ systemd.packages = [ pkgs.pdns-recursor ];
186180
187181 systemd.services.pdns-recursor = {
188− unitConfig.Documentation = "man:pdns_recursor(1) man:rec_control(1)";
189− description = "PowerDNS recursive server";
190182 wantedBy = [ "multi-user.target" ];
191− after = [ "network.target" ];
192183
193184 serviceConfig = {
194− User = username;
195− Restart ="on-failure";
196− RestartSec = "5";
197− PrivateTmp = true;
198− PrivateDevices = true;
199− AmbientCapabilities = "cap_net_bind_service";
200− ExecStart = ''${pkgs.pdns-recursor}/bin/pdns_recursor \
201− --config-dir=${dataDir} \
202− --socket-dir=${dataDir}
203− '';
185+ ExecStart = [ "" "${pkgs.pdns-recursor}/bin/pdns_recursor --config-dir=${configDir}" ];
204186 };
187+ };
205188
206− preStart = ''
207− # Link configuration file into recursor home directory
208− configPath=${dataDir}/recursor.conf
209− if [ "$(realpath $configPath)" != "${configFile}" ]; then
210− rm -f $configPath
211− ln -s ${configFile} $configPath
212− fi
213− '';
189+ users.users.pdns-recursor = {
190+ isSystemUser = true;
191+ group = "pdns-recursor";
192+ description = "PowerDNS Recursor daemon user";
214193 };
194+
195+ users.groups.pdns-recursor = {};
196+
215197 };
216198
217199 imports = [
pkgs/servers/dns/pdns-recursor/default.nix+1−1
@@ -23,7 +23,7 @@ stdenv.mkDerivation rec {
2323
2424 configureFlags = [
2525 "--enable-reproducible"
26− "--with-systemd"
26+ "--enable-systemd"
2727 ];
2828
2929 enableParallelBuilding = true;