Merge pull request #62269 from dasJ/fix-bird-reload

nixos/bird: Fix reload
This commit is contained in:
Jörg Thalheim 2019-06-09 17:34:30 +01:00 committed by GitHub
commit 98e3b90b6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,15 +14,6 @@ let
bird6 = "1.9.x with IPv6 suport"; bird6 = "1.9.x with IPv6 suport";
bird2 = "2.x"; bird2 = "2.x";
}.${variant}; }.${variant};
configFile = pkgs.stdenv.mkDerivation {
name = "${variant}.conf";
text = cfg.config;
preferLocalBuild = true;
buildCommand = ''
echo -n "$text" > $out
${pkg}/bin/${birdBin} -d -p -c $out
'';
};
in { in {
###### interface ###### interface
options = { options = {
@ -41,14 +32,24 @@ let
###### implementation ###### implementation
config = mkIf cfg.enable { config = mkIf cfg.enable {
environment.systemPackages = [ pkg ]; environment.systemPackages = [ pkg ];
environment.etc."bird/${variant}.conf".source = pkgs.writeTextFile {
name = "${variant}.conf";
text = cfg.config;
checkPhase = ''
${pkg}/bin/${birdBin} -d -p -c $out
'';
};
systemd.services.${variant} = { systemd.services.${variant} = {
description = "BIRD Internet Routing Daemon (${descr})"; description = "BIRD Internet Routing Daemon (${descr})";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
reloadIfChanged = true; reloadIfChanged = true;
restartTriggers = [ config.environment.etc."bird/${variant}.conf".source ];
serviceConfig = { serviceConfig = {
Type = "forking"; Type = "forking";
Restart = "on-failure"; Restart = "on-failure";
ExecStart = "${pkg}/bin/${birdBin} -c ${configFile} -u ${variant} -g ${variant}"; ExecStart = "${pkg}/bin/${birdBin} -c /etc/bird/${variant}.conf -u ${variant} -g ${variant}";
ExecReload = "${pkg}/bin/${birdc} configure"; ExecReload = "${pkg}/bin/${birdc} configure";
ExecStop = "${pkg}/bin/${birdc} down"; ExecStop = "${pkg}/bin/${birdc} down";
CapabilityBoundingSet = [ "CAP_CHOWN" "CAP_FOWNER" "CAP_DAC_OVERRIDE" "CAP_SETUID" "CAP_SETGID" CapabilityBoundingSet = [ "CAP_CHOWN" "CAP_FOWNER" "CAP_DAC_OVERRIDE" "CAP_SETUID" "CAP_SETGID"