mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 13:40:28 +03:00
Merge pull request #37412 from volth/varnish456
varnish4: init at 4.1.9; varnish6: init at 6.0.0
This commit is contained in:
commit
35eddf5ef1
9 changed files with 137 additions and 54 deletions
|
@ -6,13 +6,22 @@ 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";
|
||||
optionalString (cfg.extraModules != []) " -p vmod_path='${makeSearchPathOutput "lib" "lib/varnish/vmods" ([cfg.package] ++ cfg.extraModules)}' -r vmod_path";
|
||||
in
|
||||
{
|
||||
options = {
|
||||
services.varnish = {
|
||||
enable = mkEnableOption "Varnish Server";
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.varnish5;
|
||||
defaultText = "pkgs.varnish5";
|
||||
description = ''
|
||||
The package to use
|
||||
'';
|
||||
};
|
||||
|
||||
http_address = mkOption {
|
||||
type = types.str;
|
||||
default = "*:6081";
|
||||
|
@ -39,7 +48,7 @@ in
|
|||
extraModules = mkOption {
|
||||
type = types.listOf types.package;
|
||||
default = [];
|
||||
example = literalExample "[ pkgs.varnish-geoip ]";
|
||||
example = literalExample "[ pkgs.varnish5Packages.geoip ]";
|
||||
description = "
|
||||
Varnish modules (except 'std').
|
||||
";
|
||||
|
@ -73,7 +82,7 @@ in
|
|||
serviceConfig = {
|
||||
Type = "simple";
|
||||
PermissionsStartOnly = true;
|
||||
ExecStart = "${pkgs.varnish}/sbin/varnishd -a ${cfg.http_address} -n ${cfg.stateDir} -F ${cfg.extraCommandLine} ${commandLine}";
|
||||
ExecStart = "${cfg.package}/sbin/varnishd -a ${cfg.http_address} -n ${cfg.stateDir} -F ${cfg.extraCommandLine} ${commandLine}";
|
||||
Restart = "always";
|
||||
RestartSec = "5s";
|
||||
User = "varnish";
|
||||
|
@ -84,13 +93,13 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
environment.systemPackages = [ pkgs.varnish ];
|
||||
environment.systemPackages = [ cfg.package ];
|
||||
|
||||
# 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";
|
||||
buildCommand = "${cfg.package}/sbin/varnishd -C ${commandLine} 2> $out || (cat $out; exit 1)";
|
||||
})
|
||||
];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue