1
0
Fork 0
selfhostblocks/caddy/siteconfig.nix
2023-02-19 20:37:52 -08:00

51 lines
876 B
Nix

{ stdenv
, pkgs
, utils
}:
{ siteConfigDir
, runtimeDirectory
, portBinding
, bindService
, useSocket ? false
, serviceRoot ? "/usr/share/webapps/${bindService}"
, phpFpmRuntimeDirectory ? "/run/php-fpm"
, phpFastcgi ? null
, logLevel ? "WARN"
}:
let
content =
[
"root * ${serviceRoot}"
"file_server"
]
++ (
if useSocket
then [
"bind unix/${runtimeDirectory}/${bindService}.sock"
]
else []
)
++ (
if phpFastcgi
then [
"php_fastcgi unix/${phpFpmRuntimeDirectory}/${bindService}.sock"
]
else []
);
in
utils.mkConfigFile {
name = "${bindService}.config";
dir = siteConfigDir;
content = ''
:${builtins.toString portBinding} {
${builtins.concatStringsSep "\n " content}
log {
output stderr
level ${logLevel}
}
}
'';
}