3
0
Fork 0
forked from mirrors/nixpkgs

nixos/unbound: add package option (#75585)

nixos/unbound: add package option
This commit is contained in:
Silvan Mosberger 2019-12-13 03:53:28 +01:00 committed by GitHub
commit 6b50d50cd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -53,6 +53,13 @@ in
enable = mkEnableOption "Unbound domain name server";
package = mkOption {
type = types.package;
default = pkgs.unbound;
defaultText = "pkgs.unbound";
description = "The unbound package to use";
};
allowedAccess = mkOption {
default = [ "127.0.0.0/24" ];
type = types.listOf types.str;
@ -94,7 +101,7 @@ in
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.unbound ];
environment.systemPackages = [ cfg.package ];
users.users.unbound = {
description = "unbound daemon user";
@ -114,7 +121,7 @@ in
mkdir -m 0755 -p ${stateDir}/dev/
cp ${confFile} ${stateDir}/unbound.conf
${optionalString cfg.enableRootTrustAnchor ''
${pkgs.unbound}/bin/unbound-anchor -a ${rootTrustAnchorFile} || echo "Root anchor updated!"
${cfg.package}/bin/unbound-anchor -a ${rootTrustAnchorFile} || echo "Root anchor updated!"
chown unbound ${stateDir} ${rootTrustAnchorFile}
''}
touch ${stateDir}/dev/random
@ -122,7 +129,7 @@ in
'';
serviceConfig = {
ExecStart = "${pkgs.unbound}/bin/unbound -d -c ${stateDir}/unbound.conf";
ExecStart = "${cfg.package}/bin/unbound -d -c ${stateDir}/unbound.conf";
ExecStopPost="${pkgs.utillinux}/bin/umount ${stateDir}/dev/random";
ProtectSystem = true;