Merge pull request #140799 from helsinki-systems/feat/varnish-optional-configcheck

nixos/varnish: add enableConfigCheck
This commit is contained in:
Lassulus 2021-10-08 00:12:11 +02:00 committed by GitHub
commit 36187264df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,8 @@ in
services.varnish = {
enable = mkEnableOption "Varnish Server";
enableConfigCheck = mkEnableOption "checking the config during build time" // { default = true; };
package = mkOption {
type = types.package;
default = pkgs.varnish;
@ -96,11 +98,10 @@ in
environment.systemPackages = [ cfg.package ];
# check .vcl syntax at compile time (e.g. before nixops deployment)
system.extraDependencies = [
(pkgs.stdenv.mkDerivation {
name = "check-varnish-syntax";
buildCommand = "${cfg.package}/sbin/varnishd -C ${commandLine} 2> $out || (cat $out; exit 1)";
})
system.extraDependencies = mkIf cfg.enableConfigCheck [
(pkgs.runCommand "check-varnish-syntax" {} ''
${cfg.package}/bin/varnishd -C ${commandLine} 2> $out || (cat $out; exit 1)
'')
];
users.users.varnish = {