diff --git a/configs/tarot.nix b/configs/tarot.nix new file mode 100644 index 0000000..8a96a81 --- /dev/null +++ b/configs/tarot.nix @@ -0,0 +1,35 @@ +{ config, pkgs, lib, ... }: +let + tarotPort = 7407; + tarotFiles = pkgs.fetchzip { + url = "https://c.krebsco.de/tarot.zip"; + sha256 = "0jl5vdwlj17pqp94yj02xgsb1gyvs9i08m83kac0jdnhfjl2f75a"; + stripRoot = false; + }; +in +{ + krebs.htgen.tarot = { + port = tarotPort; + user.name = "radio"; + script = ''. ${pkgs.writers.writeDash "tarot" '' + case "$Method $Request_URI" in + "GET /") + if item=$(find ${toString tarotFiles} -type f | shuf -n1); then + printf 'HTTP/1.1 200 OK\r\n' + printf 'Content-Type: %s\r\n' "$(file -ib $item)" + printf 'Server: %s\r\n' "$Server" + printf 'Connection: close\r\n' + printf 'Content-Length: %d\r\n' $(wc -c < $item) + printf '\r\n' + cat $item + exit + fi + ;; + esac + ''}''; + }; + + services.nginx.virtualHosts."tarot.kmein.r" = { + locations."/".proxyPass = "http://127.0.0.1:${toString tarotPort}"; + }; +} diff --git a/systems/makanek/configuration.nix b/systems/makanek/configuration.nix index 5f38401..f79bf68 100644 --- a/systems/makanek/configuration.nix +++ b/systems/makanek/configuration.nix @@ -65,6 +65,7 @@ in + ];