···
cfg = config.services.unbound;
9
-
username = "unbound";
stateDir = "/var/lib/unbound";
access = concatMapStrings (x: " access-control: ${x} allow\n") cfg.allowedAccess;
···
confFile = pkgs.writeText "unbound.conf" ''
24
-
username: ${username}
25
-
# make sure unbound can access entropy from inside the chroot.
26
-
# e.g. on linux the use these commands (on BSD, devfs(8) is used):
27
-
# mount --bind -n /dev/random /etc/unbound/dev/random
28
-
# and mount --bind -n /dev/log /etc/unbound/dev/log
30
-
# logfile: "${stateDir}/unbound.log" #uncomment to use logfile.
31
-
pidfile: "${stateDir}/unbound.pid"
32
-
verbosity: 1 # uncomment and increase to get more logging.
···
environment.systemPackages = [ pkgs.unbound ];
users.extraUsers = singleton {
uid = config.ids.uids.unbound;
description = "unbound daemon user";
···
wants = [" nss-lookup.target" ];
wantedBy = [ "multi-user.target" ];
99
-
path = [ pkgs.unbound ];
100
-
serviceConfig.ExecStart = "${pkgs.unbound}/sbin/unbound -d -c ${confFile}";
90
+
mkdir -m 0755 -p ${stateDir}/dev/
91
+
cp ${confFile} ${stateDir}/unbound.conf
92
+
chown unbound ${stateDir}
93
+
touch ${stateDir}/dev/random
94
+
${pkgs.utillinux}/bin/mount --bind -n /dev/random ${stateDir}/dev/random
98
+
ExecStart = "${pkgs.unbound}/sbin/unbound -d -c ${stateDir}/unbound.conf";
99
+
ExecStopPost="${pkgs.utillinux}/bin/umount ${stateDir}/dev/random";