mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nixos/unbound: add package option
This commit is contained in:
parent
cf5c943f45
commit
018c0445ba
1 changed files with 10 additions and 3 deletions
|
@ -53,6 +53,13 @@ in
|
||||||
|
|
||||||
enable = mkEnableOption "Unbound domain name server";
|
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 {
|
allowedAccess = mkOption {
|
||||||
default = [ "127.0.0.0/24" ];
|
default = [ "127.0.0.0/24" ];
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
|
@ -94,7 +101,7 @@ in
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
environment.systemPackages = [ pkgs.unbound ];
|
environment.systemPackages = [ cfg.package ];
|
||||||
|
|
||||||
users.users.unbound = {
|
users.users.unbound = {
|
||||||
description = "unbound daemon user";
|
description = "unbound daemon user";
|
||||||
|
@ -114,7 +121,7 @@ in
|
||||||
mkdir -m 0755 -p ${stateDir}/dev/
|
mkdir -m 0755 -p ${stateDir}/dev/
|
||||||
cp ${confFile} ${stateDir}/unbound.conf
|
cp ${confFile} ${stateDir}/unbound.conf
|
||||||
${optionalString cfg.enableRootTrustAnchor ''
|
${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}
|
chown unbound ${stateDir} ${rootTrustAnchorFile}
|
||||||
''}
|
''}
|
||||||
touch ${stateDir}/dev/random
|
touch ${stateDir}/dev/random
|
||||||
|
@ -122,7 +129,7 @@ in
|
||||||
'';
|
'';
|
||||||
|
|
||||||
serviceConfig = {
|
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";
|
ExecStopPost="${pkgs.utillinux}/bin/umount ${stateDir}/dev/random";
|
||||||
|
|
||||||
ProtectSystem = true;
|
ProtectSystem = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue