3
0
Fork 0
forked from mirrors/nixpkgs

caddy service: initial implementation

This commit is contained in:
Angus Gibson 2016-04-05 01:30:21 +00:00
parent f5d05ddd87
commit bb6408ba16
3 changed files with 56 additions and 0 deletions

View file

@ -259,6 +259,7 @@
hydra-www = 236;
syncthing = 237;
mfi = 238;
caddy = 239;
# When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
@ -489,6 +490,7 @@
radicale = 234;
syncthing = 237;
#mfi = 238; # unused
caddy = 239;
# When adding a gid, make sure it doesn't match an existing
# uid. Users and groups with the same name should have equal

View file

@ -433,6 +433,7 @@
./services/ttys/kmscon.nix
./services/web-apps/pump.io.nix
./services/web-servers/apache-httpd/default.nix
./services/web-servers/caddy.nix
./services/web-servers/fcgiwrap.nix
./services/web-servers/jboss/default.nix
./services/web-servers/lighttpd/cgit.nix

View file

@ -0,0 +1,53 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.caddy;
configFile = pkgs.writeText "Caddyfile" cfg.config;
in
{
options.services.caddy = {
enable = mkEnableOption "Caddy web server";
config = mkOption {
description = "Verbatim Caddyfile to use";
};
email = mkOption {
default = "";
type = types.string;
description = "Email address (for Let's Encrypt certificate)";
};
dataDir = mkOption {
default = "/var/lib/caddy";
type = types.path;
description = "The data directory, for storing certificates.";
};
};
config = mkIf cfg.enable {
systemd.services.caddy = {
description = "Caddy web server";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${pkgs.caddy}/bin/caddy -conf=${configFile} -email=${cfg.email}";
Type = "simple";
User = "caddy";
Group = "caddy";
AmbientCapabilities = "cap_net_bind_service";
};
};
users.extraUsers.caddy = {
group = "caddy";
uid = config.ids.uids.caddy;
home = cfg.dataDir;
createHome = true;
};
users.extraGroups.caddy.gid = config.ids.uids.caddy;
};
}