{ inputs, config, ... }: let hmModules = config.flake.modules.homeManager; nixosModules = config.flake.modules.nixos; in { flake.modules.nixos.ai = { pkgs, ... }: let codexConfig = (pkgs.formats.toml { }).generate "codex-config.toml" { model = "gpt-5.6-sol"; model_reasoning_effort = "high"; plan_mode_reasoning_effort = "high"; service_tier = "default"; approvals_reviewer = "auto_review"; tui = { status_line = [ "model-with-reasoning" "current-dir" "context-remaining" "five-hour-limit" "weekly-limit" "git-branch" ]; status_line_use_colors = true; }; mcp_servers = { context7 = { url = "https://mcp.context7.com/mcp"; env_http_headers.CONTEXT7_API_KEY = "CONTEXT7_API_KEY"; }; nixos = { command = "${pkgs.uv}/bin/uvx"; args = [ "mcp-nixos" ]; startup_timeout_sec = 60.0; tools.nix.approval_mode = "approve"; }; openaiDeveloperDocs.url = "https://developers.openai.com/mcp"; }; }; in { imports = [ nixosModules.podman ]; home-manager.sharedModules = [ hmModules.ai ]; environment.etc."codex/config.toml".source = codexConfig; nixpkgs.overlays = [ inputs.llm-agents.overlays.shared-nixpkgs ]; nix.settings = { extra-substituters = [ "https://cache.numtide.com" ]; extra-trusted-public-keys = [ "niks3.numtide.com-1:DTx8wZduET09hRmMtKdQDxNNthLQETkc/yaX7M4qK0g=" ]; }; services.ollama = { enable = true; package = pkgs.ollama-vulkan; loadModels = [ "nomic-embed-text" ]; }; }; flake.modules.homeManager.ai = { pkgs, ... }: { services.podman = { volumes = { grounded-docs-config = { }; grounded-docs-data = { }; }; containers.grounded-docs = { image = "ghcr.io/arabold/docs-mcp-server:2.4.0"; network = "host"; volumes = [ "grounded-docs-config.volume:/config" "grounded-docs-data.volume:/data" ]; environment = { DOCS_MCP_APP_TELEMETRY_ENABLED = "false"; DOCS_MCP_EMBEDDING_MODEL = "openai:nomic-embed-text"; DOCS_MCP_EMBEDDINGS_VECTOR_DIMENSION = "768"; OPENAI_API_BASE = "http://127.0.0.1:11434/v1"; OPENAI_API_KEY = "ollama"; }; exec = "--protocol http --host 127.0.0.1 --port 6280"; }; }; home.packages = [ pkgs.llm-agents.codex pkgs.llm-agents.pi pkgs.llm-agents.claude-code pkgs.llm-agents.herdr pkgs.ctx7 ]; home.file.".codex/AGENTS.md".text = '' # Environment This is Nix; use `nix run` for missing commands. - Default Nix commands to `--quiet`; inspect logs only for failing derivations. - Never emit full package, derivation, closure, GC, or store-tree listings. Capture them in `/tmp`, summarize or filter, then inspect targeted excerpts. - For store sources, locate files first, then read exact ranges; avoid broad `rg -C` searches. # Work - Inspect the relevant implementation and follow project conventions. - Prefer the simplest complete solution. - Identify and address root causes rather than masking symptoms. - Prefer existing capabilities and defaults. Add custom code, wrappers, helpers, defensive checks, fallbacks, compatibility layers, or abstractions only for a concrete need. - Delete unnecessary code; keep related logic together. - Use types, schemas, and interfaces to prevent invalid states where practical. - Keep changes focused; preserve behavior unless requested or fixing a confirmed defect. - Verify unfamiliar, version-sensitive, or consequential APIs against current documentation; prefer context7. - Run the most relevant checks; report only verification performed. # Reviews and refactoring - Inspect complete relevant context, not just the obvious file or diff. - Find unnecessary or duplicated code, redundant state, avoidable checks, reimplemented capabilities, and repeated defaults. - Ask whether defensive code protects a realistic state or hides an unclear invariant. - Optimize conceptual complexity, not line count. - Separate confirmed problems from optional improvements; explain important tradeoffs. # Context Every action must justify its context. Minimize tools and skills; prefer targeted queries and bounded output. Ask for readily available large output instead of retrieving it. ''; }; }