bert: Add bible.chandlerswift.com

This commit is contained in:
Chandler Swift 2025-07-21 22:35:49 -05:00
parent fba42c5f18
commit d69b4cf8ab
Signed by: chandlerswift
GPG key ID: A851D929D52FB93F
3 changed files with 73 additions and 0 deletions

View file

@ -0,0 +1,48 @@
{ pkgs, ... }:
let
bibleApiPackage = pkgs.stdenv.mkDerivation {
pname = "bible-api";
version = "2025-07-18";
src = pkgs.fetchzip {
url = "https://bible.helloao.org/api.zip";
hash = "sha256-bYl8svY++D0+YHXZ8/3h+yn0xiqIDCXcN+Hh9FjP98k=";
stripRoot = false;
};
dontBuild = true;
installPhase = ''
mkdir -p $out/api
mv * $out/api/
'';
};
in {
services.caddy.enable = true;
services.caddy.virtualHosts."bible.chandlerswift.com" = {
extraConfig = ''
encode zstd gzip
file_server
root * ${bibleApiPackage}
handle / {
header Content-Type text/html
# This is a bit of a hack, but I was unable to find a better way to just
# serve the contents of the file. If I knew the directory of the file
# and its filename, I think I could use file_server with try_files, but
# if I do a `file_server` with `.\${./bible.chandlerswift.com.html}`, then
# bible.chandlerswift.com.html just gets copied as a file into nix-store
# and I don't know its name. ...or something? Anyway this seems to work!
respond <<EOF
${builtins.readFile ./bible.chandlerswift.com.html}
EOF
}
handle_errors {
respond "{err.status_code} {err.status_text}"
}
'';
};
}