From d1df81bf71725e7d4cee7db29151aa888678fd54 Mon Sep 17 00:00:00 2001 From: William Date: Fri, 17 Apr 2026 22:50:43 -0300 Subject: [PATCH] alexandria: serve opencode web at ai.baduhai.dev --- aspects/hosts/_alexandria/ai.nix | 31 +++++++++++++++++++++++++++++++ data/services.nix | 5 +++++ 2 files changed, 36 insertions(+) create mode 100644 aspects/hosts/_alexandria/ai.nix diff --git a/aspects/hosts/_alexandria/ai.nix b/aspects/hosts/_alexandria/ai.nix new file mode 100644 index 0000000..0969177 --- /dev/null +++ b/aspects/hosts/_alexandria/ai.nix @@ -0,0 +1,31 @@ +{ inputs, pkgs, ... }: + +let + mkNginxVHosts = inputs.self.lib.mkNginxVHosts; + opencodePort = 58801; + opencodePackage = inputs.nix-ai-tools.packages.${pkgs.stdenv.hostPlatform.system}.opencode; +in + +{ + services.nginx.virtualHosts = mkNginxVHosts { + domains = { + "ai.baduhai.dev".locations."/".proxyPass = "http://127.0.0.1:${toString opencodePort}/"; + }; + }; + + systemd.services.opencode-web = { + description = "OpenCode Web UI"; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + serviceConfig = { + Type = "simple"; + DynamicUser = true; + StateDirectory = "opencode-web"; + WorkingDirectory = "/var/lib/opencode-web"; + Environment = "HOME=/var/lib/opencode-web"; + ExecStart = "${opencodePackage}/bin/opencode web --hostname 127.0.0.1 --port ${toString opencodePort}"; + Restart = "on-failure"; + RestartSec = "5s"; + }; + }; +} diff --git a/data/services.nix b/data/services.nix index bc61b67..fc749ba 100644 --- a/data/services.nix +++ b/data/services.nix @@ -43,5 +43,10 @@ domain = "read.baduhai.dev"; host = "alexandria"; } + { + name = "opencode-web"; + domain = "ai.baduhai.dev"; + host = "alexandria"; + } ]; }