diff options
author | volth <volth@webmaster.ms> | 2017-11-26 08:13:09 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-26 08:13:09 +0000 |
commit | 25b178c74568d8f4789698e74d62570c586523e9 (patch) | |
tree | 5d3e2b454641897f8a4acc9de1d0a947485544bf /nixos/modules/services/web-servers/varnish | |
parent | d8473c35df0f30c47d150f1e77b13c29f31cca96 (diff) | |
download | nixlib-25b178c74568d8f4789698e74d62570c586523e9.tar nixlib-25b178c74568d8f4789698e74d62570c586523e9.tar.gz nixlib-25b178c74568d8f4789698e74d62570c586523e9.tar.bz2 nixlib-25b178c74568d8f4789698e74d62570c586523e9.tar.lz nixlib-25b178c74568d8f4789698e74d62570c586523e9.tar.xz nixlib-25b178c74568d8f4789698e74d62570c586523e9.tar.zst nixlib-25b178c74568d8f4789698e74d62570c586523e9.zip |
nixos/varnish: check .vcl syntax at compile time (e.g. before nixops deployment)
Diffstat (limited to 'nixos/modules/services/web-servers/varnish')
-rw-r--r-- | nixos/modules/services/web-servers/varnish/default.nix | 18 |
1 files changed, 15 insertions, 3 deletions
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; |