nixos/bird: add services.bird*.checkConfig option

This is useful when the config doesn't entirely live in the Nix store,
but is configured to include mutable config files written at runtime.

Co-Authored-By: Puck Meerburg <puck@puck.moe>
This commit is contained in:
Florian Klink 2021-03-18 14:17:43 +01:00
parent 96cb2a4d79
commit 7d266264ce

View file

@ -1,7 +1,7 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let let
inherit (lib) mkEnableOption mkIf mkOption types; inherit (lib) mkEnableOption mkIf mkOption optionalString types;
generic = variant: generic = variant:
let let
@ -26,6 +26,14 @@ let
<link xlink:href='http://bird.network.cz/'/> <link xlink:href='http://bird.network.cz/'/>
''; '';
}; };
checkConfig = mkOption {
type = types.bool;
default = true;
description = ''
Whether the config should be checked at build time.
Disabling this might become necessary if the config includes files not present during build time.
'';
};
}; };
}; };
@ -36,7 +44,7 @@ let
environment.etc."bird/${variant}.conf".source = pkgs.writeTextFile { environment.etc."bird/${variant}.conf".source = pkgs.writeTextFile {
name = "${variant}.conf"; name = "${variant}.conf";
text = cfg.config; text = cfg.config;
checkPhase = '' checkPhase = optionalString cfg.checkConfig ''
${pkg}/bin/${birdBin} -d -p -c $out ${pkg}/bin/${birdBin} -d -p -c $out
''; '';
}; };