From 25b178c74568d8f4789698e74d62570c586523e9 Mon Sep 17 00:00:00 2001 From: volth Date: Sun, 26 Nov 2017 08:13:09 +0000 Subject: nixos/varnish: check .vcl syntax at compile time (e.g. before nixops deployment) --- nixos/modules/services/web-servers/varnish/default.nix | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'nixos/modules') diff --git a/nixos/modules/services/web-servers/varnish/default.nix b/nixos/modules/services/web-servers/varnish/default.nix index c3bc065d4651..832952b6ce0d 100644 --- a/nixos/modules/services/web-servers/varnish/default.nix +++ b/nixos/modules/services/web-servers/varnish/default.nix @@ -1,9 +1,13 @@ { config, lib, pkgs, ...}: + +with lib; + let cfg = config.services.varnish; + commandLine = "-f ${pkgs.writeText "default.vcl" cfg.config}" + + optionalString (cfg.extraModules != []) " -p vmod_path='${makeSearchPathOutput "lib" "lib/varnish/vmods" ([pkgs.varnish] ++ cfg.extraModules)}' -r vmod_path"; in -with lib; { options = { services.varnish = { @@ -69,8 +73,7 @@ with lib; serviceConfig = { Type = "simple"; PermissionsStartOnly = true; - ExecStart = "${pkgs.varnish}/sbin/varnishd -a ${cfg.http_address} -f ${pkgs.writeText "default.vcl" cfg.config} -n ${cfg.stateDir} -F ${cfg.extraCommandLine}" - + optionalString (cfg.extraModules != []) " -p vmod_path='${makeSearchPathOutput "lib" "lib/varnish/vmods" ([pkgs.varnish] ++ cfg.extraModules)}' -r vmod_path"; + ExecStart = "${pkgs.varnish}/sbin/varnishd -a ${cfg.http_address} -n ${cfg.stateDir} -F ${cfg.extraCommandLine} ${commandLine}"; Restart = "always"; RestartSec = "5s"; User = "varnish"; @@ -83,6 +86,15 @@ with lib; environment.systemPackages = [ pkgs.varnish ]; + # check .vcl syntax at compile time (e.g. before nixops deployment) + system.extraDependencies = [ + (pkgs.stdenv.mkDerivation { + name = "check-varnish-syntax"; + preferLocalBuild = true; + buildCommand = "${pkgs.varnish}/sbin/varnishd -C ${commandLine} 2> $out"; + }) + ]; + users.extraUsers.varnish = { group = "varnish"; uid = config.ids.uids.varnish; -- cgit 1.4.1 From bfee33661493df9d995f581ffea542d25ccbbcc9 Mon Sep 17 00:00:00 2001 From: volth Date: Sat, 9 Dec 2017 08:29:44 +0000 Subject: nixos/varnish: it does not matter where to check syntax, only when --- nixos/modules/services/web-servers/varnish/default.nix | 1 - 1 file changed, 1 deletion(-) (limited to 'nixos/modules') diff --git a/nixos/modules/services/web-servers/varnish/default.nix b/nixos/modules/services/web-servers/varnish/default.nix index 832952b6ce0d..d63fb954ef96 100644 --- a/nixos/modules/services/web-servers/varnish/default.nix +++ b/nixos/modules/services/web-servers/varnish/default.nix @@ -90,7 +90,6 @@ in system.extraDependencies = [ (pkgs.stdenv.mkDerivation { name = "check-varnish-syntax"; - preferLocalBuild = true; buildCommand = "${pkgs.varnish}/sbin/varnishd -C ${commandLine} 2> $out"; }) ]; -- cgit 1.4.1