mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
Add varnish module
This commit is contained in:
parent
23a2f4675f
commit
0f930a00f8
1 changed files with 54 additions and 0 deletions
54
modules/services/web-servers/varnish/default.nix
Normal file
54
modules/services/web-servers/varnish/default.nix
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
{ config, pkgs, ...}:
|
||||||
|
let
|
||||||
|
cfg = config.services.varnish;
|
||||||
|
in
|
||||||
|
with pkgs.lib;
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
services.varnish = {
|
||||||
|
enable = mkOption {
|
||||||
|
default = false;
|
||||||
|
description = "
|
||||||
|
Enable the Varnish Server.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkOption {
|
||||||
|
description = "
|
||||||
|
Verbatim default.vcl configuration.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
stateDir = mkOption {
|
||||||
|
default = "/var/spool/varnish";
|
||||||
|
description = "
|
||||||
|
Directory holding all state for Varnish to run.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
|
systemd.services.varnish = {
|
||||||
|
description = "Varnish";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
preStart = ''
|
||||||
|
mkdir -p ${cfg.stateDir}
|
||||||
|
chown -R varnish:varnish ${cfg.stateDir}
|
||||||
|
'';
|
||||||
|
path = [ pkgs.gcc ];
|
||||||
|
serviceConfig.ExecStart = "${pkgs.varnish}/sbin/varnishd -f ${pkgs.writeText "default.vcl" cfg.config} -n ${cfg.stateDir} -u varnish";
|
||||||
|
serviceConfig.Type = "forking";
|
||||||
|
};
|
||||||
|
|
||||||
|
environment.systemPackages = [ pkgs.varnish ];
|
||||||
|
|
||||||
|
users.extraUsers.varnish = {
|
||||||
|
group = "varnish";
|
||||||
|
};
|
||||||
|
|
||||||
|
users.extraGroups.varnish = {};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue