3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #32062 from volth/patch-73

nixos/varnish: check .vcl syntax at compile time
This commit is contained in:
Joachim F 2018-02-20 19:22:28 +00:00 committed by GitHub
commit 46afc63b6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,14 @@ 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";
buildCommand = "${pkgs.varnish}/sbin/varnishd -C ${commandLine} 2> $out";
})
];
users.extraUsers.varnish = {
group = "varnish";
uid = config.ids.uids.varnish;