bert: Add bible.chandlerswift.com
This commit is contained in:
parent
fba42c5f18
commit
d69b4cf8ab
3 changed files with 73 additions and 0 deletions
48
bert/services/http/bible.chandlerswift.com.nix
Normal file
48
bert/services/http/bible.chandlerswift.com.nix
Normal 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}"
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue