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.
This commit is contained in:
parent
3fe7cddc30
commit
0034f9e52c
|
@ -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 {
|
extraConfig = mkOption {
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
default = "";
|
default = "";
|
||||||
|
@ -101,10 +109,12 @@ in
|
||||||
BusName = "uk.org.thekelleys.dnsmasq";
|
BusName = "uk.org.thekelleys.dnsmasq";
|
||||||
ExecStart = "${dnsmasq}/bin/dnsmasq -k --enable-dbus --user=dnsmasq -C ${dnsmasqConf}";
|
ExecStart = "${dnsmasq}/bin/dnsmasq -k --enable-dbus --user=dnsmasq -C ${dnsmasqConf}";
|
||||||
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
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 ];
|
restartTriggers = [ config.environment.etc.hosts.source ];
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue