nixos/varnish: check .vcl syntax at compile time (e.g. before nixops deployment)
This commit is contained in:
parent
d8473c35df
commit
25b178c745
@ -1,9 +1,13 @@
|
|||||||
{ config, lib, pkgs, ...}:
|
{ config, lib, pkgs, ...}:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.services.varnish;
|
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
|
in
|
||||||
with lib;
|
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
services.varnish = {
|
services.varnish = {
|
||||||
@ -69,8 +73,7 @@ with lib;
|
|||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
PermissionsStartOnly = true;
|
PermissionsStartOnly = true;
|
||||||
ExecStart = "${pkgs.varnish}/sbin/varnishd -a ${cfg.http_address} -f ${pkgs.writeText "default.vcl" cfg.config} -n ${cfg.stateDir} -F ${cfg.extraCommandLine}"
|
ExecStart = "${pkgs.varnish}/sbin/varnishd -a ${cfg.http_address} -n ${cfg.stateDir} -F ${cfg.extraCommandLine} ${commandLine}";
|
||||||
+ optionalString (cfg.extraModules != []) " -p vmod_path='${makeSearchPathOutput "lib" "lib/varnish/vmods" ([pkgs.varnish] ++ cfg.extraModules)}' -r vmod_path";
|
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
RestartSec = "5s";
|
RestartSec = "5s";
|
||||||
User = "varnish";
|
User = "varnish";
|
||||||
@ -83,6 +86,15 @@ with lib;
|
|||||||
|
|
||||||
environment.systemPackages = [ pkgs.varnish ];
|
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 = {
|
users.extraUsers.varnish = {
|
||||||
group = "varnish";
|
group = "varnish";
|
||||||
uid = config.ids.uids.varnish;
|
uid = config.ids.uids.varnish;
|
||||||
|
Loading…
Reference in New Issue
Block a user