about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorPeter Hoeg <peter@hoeg.com>2017-10-11 23:13:37 +0800
committerPeter Hoeg <peter@hoeg.com>2017-10-14 14:38:04 +0800
commit1917e69b546bc357652a3fd888c064e2a1c9fed8 (patch)
tree47f5464f819df74a18a924cf66dca1f35d346e13 /nixos
parent65b73d71cbe5df15ce62024123eedea284d825db (diff)
downloadnixlib-1917e69b546bc357652a3fd888c064e2a1c9fed8.tar
nixlib-1917e69b546bc357652a3fd888c064e2a1c9fed8.tar.gz
nixlib-1917e69b546bc357652a3fd888c064e2a1c9fed8.tar.bz2
nixlib-1917e69b546bc357652a3fd888c064e2a1c9fed8.tar.lz
nixlib-1917e69b546bc357652a3fd888c064e2a1c9fed8.tar.xz
nixlib-1917e69b546bc357652a3fd888c064e2a1c9fed8.tar.zst
nixlib-1917e69b546bc357652a3fd888c064e2a1c9fed8.zip
dnsmasq nixos: make sure it always runs
By default we only restart if the dnsmasq daemon fails but we introduce an
option to always keep it running.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/networking/dnsmasq.nix14
1 files changed, 12 insertions, 2 deletions
diff --git a/nixos/modules/services/networking/dnsmasq.nix b/nixos/modules/services/networking/dnsmasq.nix
index fcf5aa5f175b..91a3e54474ac 100644
--- a/nixos/modules/services/networking/dnsmasq.nix
+++ b/nixos/modules/services/networking/dnsmasq.nix
@@ -55,6 +55,14 @@ in
         '';
       };
 
+      alwaysKeepRunning = mkOption {
+        type = types.bool;
+        default = false;
+        description = ''
+          If enabled, systemd will always respawn dnsmasq even if shut down manually. The default, disabled, will only restart it on error.
+        '';
+      };
+
       extraConfig = mkOption {
         type = types.lines;
         default = "";
@@ -101,10 +109,12 @@ in
           BusName = "uk.org.thekelleys.dnsmasq";
           ExecStart = "${dnsmasq}/bin/dnsmasq -k --enable-dbus --user=dnsmasq -C ${dnsmasqConf}";
           ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
+          PrivateTmp = true;
+          ProtectSystem = true;
+          ProtectHome = true;
+          Restart = if cfg.alwaysKeepRunning then "always" else "on-failure";
         };
         restartTriggers = [ config.environment.etc.hosts.source ];
     };
-
   };
-
 }