1
0
Fork 0
selfhostblocks/caddy/siteconfig.nix

50 lines
782 B
Nix
Raw Normal View History

2022-09-09 08:26:33 +02:00
{ stdenv
, pkgs
, utils
}:
{ siteConfigDir
, portBinding
, bindService
, serviceRoot ? "/usr/share/webapps/${bindService}"
2022-09-10 08:15:03 +02:00
, siteSocket ? null
, phpFpmSiteSocket ? null
2022-09-09 08:26:33 +02:00
, logLevel ? "WARN"
}:
let
content =
[
"root * ${serviceRoot}"
"file_server"
]
++ (
2022-09-10 08:15:03 +02:00
if siteSocket != ""
2022-09-09 08:26:33 +02:00
then [
2022-09-10 08:15:03 +02:00
"bind unix/${siteSocket}"
2022-09-09 08:26:33 +02:00
]
else []
)
++ (
2022-09-10 08:15:03 +02:00
if phpFpmSiteSocket != ""
2022-09-09 08:26:33 +02:00
then [
2022-09-10 08:15:03 +02:00
"php_fastcgi unix/${phpFpmSiteSocket}"
2022-09-09 08:26:33 +02:00
]
else []
);
in
utils.mkConfigFile {
name = "${bindService}.config";
dir = siteConfigDir;
content = ''
:${builtins.toString portBinding} {
2022-09-10 08:15:03 +02:00
${builtins.concatStringsSep "\n " content}
2022-09-09 08:26:33 +02:00
log {
2022-09-10 08:15:03 +02:00
output stderr
level ${logLevel}
2022-09-09 08:26:33 +02:00
}
}
'';
}