@@ -13,6 +13,8 @@ in
1313 services.varnish = {
1414 enable = mkEnableOption "Varnish Server";
1515
16+ enableConfigCheck = mkEnableOption "checking the config during build time" // { default = true; };
17+
1618 package = mkOption {
1719 type = types.package;
1820 default = pkgs.varnish;
@@ -96,11 +98,10 @@ in
9698 environment.systemPackages = [ cfg.package ];
9799
98100 # check .vcl syntax at compile time (e.g. before nixops deployment)
99− system.extraDependencies = [
100− (pkgs.stdenv.mkDerivation {
101− name = "check-varnish-syntax";
102− buildCommand = "${cfg.package}/sbin/varnishd -C ${commandLine} 2> $out || (cat $out; exit 1)";
103− })
101+ system.extraDependencies = mkIf cfg.enableConfigCheck [
102+ (pkgs.runCommand "check-varnish-syntax" {} ''
103+ ${cfg.package}/bin/varnishd -C ${commandLine} 2> $out || (cat $out; exit 1)
104+ '')
104105 ];
105106
106107 users.users.varnish = {