merge config with unit for caddy
This commit is contained in:
parent
2213db7ce9
commit
e41918a1a7
2 changed files with 14 additions and 28 deletions
|
@ -1,22 +0,0 @@
|
||||||
{ stdenv
|
|
||||||
, pkgs
|
|
||||||
, utils
|
|
||||||
}:
|
|
||||||
{ configDir ? "/etc/caddy"
|
|
||||||
, configFile ? "Caddyfile"
|
|
||||||
, siteConfigDir
|
|
||||||
}:
|
|
||||||
|
|
||||||
utils.mkConfigFile {
|
|
||||||
name = configFile;
|
|
||||||
dir = configDir;
|
|
||||||
content = ''
|
|
||||||
{
|
|
||||||
# Disable auto https
|
|
||||||
http_port 10001
|
|
||||||
https_port 10002
|
|
||||||
}
|
|
||||||
|
|
||||||
import ${siteConfigDir}/*
|
|
||||||
'';
|
|
||||||
}
|
|
|
@ -4,11 +4,21 @@
|
||||||
}:
|
}:
|
||||||
{ user ? "http"
|
{ user ? "http"
|
||||||
, group ? "http"
|
, group ? "http"
|
||||||
, configDir ? "/etc/caddy"
|
, siteConfigDir
|
||||||
, configFile ? "Caddyfile"
|
|
||||||
}:
|
}:
|
||||||
{...}:
|
{...}:
|
||||||
|
|
||||||
|
let
|
||||||
|
config = pkgs.writeTextDir "Caddyfile" ''
|
||||||
|
{
|
||||||
|
# Disable auto https
|
||||||
|
http_port 10001
|
||||||
|
https_port 10002
|
||||||
|
}
|
||||||
|
|
||||||
|
import ${siteConfigDir}/*
|
||||||
|
'';
|
||||||
|
in
|
||||||
utils.systemd.mkService rec {
|
utils.systemd.mkService rec {
|
||||||
name = "caddy";
|
name = "caddy";
|
||||||
|
|
||||||
|
@ -27,10 +37,8 @@ utils.systemd.mkService rec {
|
||||||
Type=notify
|
Type=notify
|
||||||
User=${user}
|
User=${user}
|
||||||
Group=${group}
|
Group=${group}
|
||||||
# Environment=XDG_DATA_HOME=/var/lib
|
ExecStart=${pkgs.caddy}/bin/caddy run --environ --config ${config}
|
||||||
# Environment=XDG_CONFIG_HOME=${configDir}
|
ExecReload=${pkgs.caddy}/bin/caddy reload --config ${config}
|
||||||
ExecStart=${pkgs.caddy}/bin/caddy run --environ --config ${configDir}/${configFile}
|
|
||||||
ExecReload=${pkgs.caddy}/bin/caddy reload --config ${configDir}/${configFile}
|
|
||||||
|
|
||||||
# Restart=on-abnormal
|
# Restart=on-abnormal
|
||||||
RuntimeDirectory=caddy
|
RuntimeDirectory=caddy
|
||||||
|
|
Loading…
Reference in a new issue