lol

Merge pull request #32062 from volth/patch-73

nixos/varnish: check .vcl syntax at compile time

authored by

Joachim F and committed by
GitHub
46afc63b b30fae01

+14 -3
+14 -3
nixos/modules/services/web-servers/varnish/default.nix
··· 1 1 { config, lib, pkgs, ...}: 2 + 3 + with lib; 4 + 2 5 let 3 6 cfg = config.services.varnish; 4 7 8 + commandLine = "-f ${pkgs.writeText "default.vcl" cfg.config}" + 9 + optionalString (cfg.extraModules != []) " -p vmod_path='${makeSearchPathOutput "lib" "lib/varnish/vmods" ([pkgs.varnish] ++ cfg.extraModules)}' -r vmod_path"; 5 10 in 6 - with lib; 7 11 { 8 12 options = { 9 13 services.varnish = { ··· 69 73 serviceConfig = { 70 74 Type = "simple"; 71 75 PermissionsStartOnly = true; 72 - ExecStart = "${pkgs.varnish}/sbin/varnishd -a ${cfg.http_address} -f ${pkgs.writeText "default.vcl" cfg.config} -n ${cfg.stateDir} -F ${cfg.extraCommandLine}" 73 - + optionalString (cfg.extraModules != []) " -p vmod_path='${makeSearchPathOutput "lib" "lib/varnish/vmods" ([pkgs.varnish] ++ cfg.extraModules)}' -r vmod_path"; 76 + ExecStart = "${pkgs.varnish}/sbin/varnishd -a ${cfg.http_address} -n ${cfg.stateDir} -F ${cfg.extraCommandLine} ${commandLine}"; 74 77 Restart = "always"; 75 78 RestartSec = "5s"; 76 79 User = "varnish"; ··· 82 85 }; 83 86 84 87 environment.systemPackages = [ pkgs.varnish ]; 88 + 89 + # check .vcl syntax at compile time (e.g. before nixops deployment) 90 + system.extraDependencies = [ 91 + (pkgs.stdenv.mkDerivation { 92 + name = "check-varnish-syntax"; 93 + buildCommand = "${pkgs.varnish}/sbin/varnishd -C ${commandLine} 2> $out"; 94 + }) 95 + ]; 85 96 86 97 users.extraUsers.varnish = { 87 98 group = "varnish";