diff --git a/hosts/server/configuration.nix b/hosts/server/configuration.nix index 154ee50..7fec228 100644 --- a/hosts/server/configuration.nix +++ b/hosts/server/configuration.nix @@ -15,6 +15,7 @@ ./modules/gitea.nix ./modules/vaultwarden.nix ./slop/openclaw.nix + ./slop/brave.nix ]; # gcc. shit breaks. wtf diff --git a/hosts/server/slop/brave.nix b/hosts/server/slop/brave.nix new file mode 100644 index 0000000..e8846d3 --- /dev/null +++ b/hosts/server/slop/brave.nix @@ -0,0 +1,26 @@ +{ pkgs, ... }: + +{ + # Local Brave API shim as a user service + systemd.user.services.brave-shim = { + description = "Brave Search API shim (DDGS)"; + wantedBy = [ "default.target" ]; + after = [ "network-online.target" ]; + wants = [ "network-online.target" ]; + + serviceConfig = { + Type = "simple"; + WorkingDirectory = "/home/ocbwoy3/Projects/brave_shim"; + ExecStart = '' + ${pkgs.uv}/bin/uv run \ + --with fastapi \ + --with uvicorn \ + --with ddgs \ + --with pyyaml \ + python brave_shim.py + ''; + Restart = "always"; + RestartSec = "3"; + }; + }; +} diff --git a/hosts/server/slop/openclaw.nix b/hosts/server/slop/openclaw.nix index 784f378..a8a249f 100644 --- a/hosts/server/slop/openclaw.nix +++ b/hosts/server/slop/openclaw.nix @@ -4,6 +4,18 @@ ... }: +let + openclawPatched = inputs.openclaw.packages.${pkgs.system}.openclaw-gateway.overrideAttrs (old: { + postInstall = (old.postInstall or "") + '' + # Point Brave web-search endpoint to local shim + if [ -d "$out/lib/openclaw/dist" ]; then + grep -RIl "https://api.search.brave.com/" "$out/lib/openclaw/dist" | while read -r f; do + substituteInPlace "$f" --replace-fail "https://api.search.brave.com/" "http://127.0.0.1:8000/" + done + fi + ''; + }); +in { home-manager.sharedModules = [ inputs.openclaw.homeManagerModules.openclaw @@ -11,8 +23,10 @@ users.users.ocbwoy3 = { packages = [ - inputs.openclaw.packages.${pkgs.system}.openclaw-gateway + openclawPatched (pkgs.callPackage ./gogcli.nix { }) + pkgs.uv + pkgs.python3 ]; }; }