diff --git a/machine/backyard/default.nix b/machine/backyard/default.nix index 0eb9eed..4be8480 100644 --- a/machine/backyard/default.nix +++ b/machine/backyard/default.nix @@ -3,6 +3,7 @@ { imports = [ ./hardware-configuration.nix + ./fileserver.nix ./jellyfin.nix ./samba.nix ]; @@ -29,6 +30,7 @@ allowedTCPPorts = [ 7474 # mirror revproxy 7475 # http serve tvb pool + 7476 # tvb catacomb host server ]; }; @@ -60,6 +62,13 @@ ]; root = "/pool/tvb/doc/website/mirror"; }; + "files.backyard.home" = { + listen = [ + { addr = "10.22.20.8"; port = 7476; } + ]; + locations."/".tryFiles = "\$uri @indexer"; + locations."@indexer".proxyPass = "http://localhost:5000"; + }; }; }; diff --git a/machine/backyard/fileserver.nix b/machine/backyard/fileserver.nix new file mode 100644 index 0000000..adbe69c --- /dev/null +++ b/machine/backyard/fileserver.nix @@ -0,0 +1,47 @@ +# nas indexer server module +{ pkgs, ... }: + +let + # Build the catacomb server package + catacombServerSource = builtins.fetchGit { + url = "https://git.alogoulogoi.com/Jaculabilis/catacomb-server.git"; + ref = "develop-nix"; + rev = "3d6fb16948c377f94d030648849f120c8ada3884"; + }; + catacombServer = pkgs.callPackage catacombServerSource { + pkgs = import (fetchTarball { + url = "https://github.com/NixOS/nixpkgs/archive/405d762a1a05ffed2ac820eb4bae4bc49bc3abf2.tar.gz"; + sha256 = "6c835ea038bdfe170029a8bd4276c9d3a95c275159ec05426672fa8092c7947d"; + }) { + system = "x86_64-linux"; + }; + }; + + # Host-mode server run script + hostRun = pkgs.writeShellScriptBin "catacomb-run-host.sh" '' + ${catacombServer}/bin/gunicorn \ + --bind=localhost:5000 \ + --workers=3 \ + --log-level=debug \ + --env CATACOMB_ROOT=/pool/tvb \ + --env CATACOMB_MODE=host \ + --env CATACOMB_TOKENS=/var/empty \ + --env CATACOMB_GUEST_HOST=catacomb.alogoulogoi.com \ + "catacomb.server:wsgi()" + ''; +in +{ + # Set up the host mode service + systemd.services."catacomb-host" = { + enable = true; + description = "catapool host-mode index server"; + script = "${hostRun}/bin/catacomb-run-host.sh"; + serviceConfig = { + Type = "simple"; + User = "nginx"; + }; + requires = [ "zfs.target" ]; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + }; +}