From 61cabbc0ad4bc62e1f6cc0788f501e5ae4f7b106 Mon Sep 17 00:00:00 2001 From: Anish Lakhwara Date: Mon, 22 Dec 2025 15:28:09 -0800 Subject: [PATCH] feat: init raven --- home/profiles/cli/default.nix | 1 - hosts/box/default.nix | 1 + hosts/profiles/raven/default.nix | 63 ++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 hosts/profiles/raven/default.nix diff --git a/home/profiles/cli/default.nix b/home/profiles/cli/default.nix index e1458043..6451ace8 100644 --- a/home/profiles/cli/default.nix +++ b/home/profiles/cli/default.nix @@ -64,7 +64,6 @@ taskwarrior-tui # vimwiki-cli zk - unstable.opencode (pkgs.writeScriptBin "jq-repl" '' #!/usr/bin/env bash diff --git a/hosts/box/default.nix b/hosts/box/default.nix index 0c71ff87..8d0aa11f 100644 --- a/hosts/box/default.nix +++ b/hosts/box/default.nix @@ -28,6 +28,7 @@ ../profiles/jacket ../profiles/gpodder ../profiles/transmission + ../profiles/raven #../profiles/postgres_upgrade_script ]; diff --git a/hosts/profiles/raven/default.nix b/hosts/profiles/raven/default.nix new file mode 100644 index 00000000..5958c454 --- /dev/null +++ b/hosts/profiles/raven/default.nix @@ -0,0 +1,63 @@ +{ pkgs, config, lib, ... }: +{ + # =================== + # Ollama Service + # =================== + services.ollama = { + enable = true; + acceleration = null; # CPU only, no GPU + host = "127.0.0.1"; + port = 11434; + }; + + # =================== + # PostgreSQL: Letta Database + # =================== + services.postgresql = { + enable = true; + ensureDatabases = [ "letta" ]; + ensureUsers = [ + { + name = "letta"; + ensureDBOwnership = true; + } + ]; + + # Enable TCP connections (required for Docker) + enableTCPIP = true; + + # Allow letta user to connect via TCP with password + authentication = lib.mkAfter '' + # Letta database - TCP password auth for Docker + host letta letta 127.0.0.1/32 scram-sha-256 + host letta letta ::1/128 scram-sha-256 + ''; + + # Include pgvector extension + extraPlugins = ps: [ ps.pgvector ]; + }; + + # =================== + # Database Setup Service + # =================== + # Runs after postgresql to enable pgvector and set password + systemd.services.raven-db-setup = { + description = "Setup Letta database with pgvector and password"; + after = [ "postgresql.service" ]; + wantedBy = [ "multi-user.target" ]; + path = [ config.services.postgresql.package ]; + serviceConfig = { + Type = "oneshot"; + User = "postgres"; + RemainAfterExit = true; + }; + script = '' + # Enable pgvector extension + psql -d letta -c "CREATE EXTENSION IF NOT EXISTS vector;" + + # Set password for letta user + # TODO: Consider using agenix for production + psql -c "ALTER USER letta WITH PASSWORD 'letta-dev-password';" + ''; + }; +}