From 3ee33e4bfdfb6768594e69cec663d1439af211f8 Mon Sep 17 00:00:00 2001 From: mjallen18 Date: Thu, 19 Mar 2026 16:34:27 -0500 Subject: [PATCH] couple fixes --- .../matt@macbook-pro-nixos/default.nix | 1 + .../x86_64-linux/admin@jallen-nas/default.nix | 93 +------------------ modules/home/programs/opencode/default.nix | 87 +++++++++++++++++ 3 files changed, 93 insertions(+), 88 deletions(-) create mode 100644 modules/home/programs/opencode/default.nix diff --git a/homes/aarch64-linux/matt@macbook-pro-nixos/default.nix b/homes/aarch64-linux/matt@macbook-pro-nixos/default.nix index 02828c4..f1b6f53 100755 --- a/homes/aarch64-linux/matt@macbook-pro-nixos/default.nix +++ b/homes/aarch64-linux/matt@macbook-pro-nixos/default.nix @@ -83,6 +83,7 @@ in nwg-dock = disabled; nwg-drawer = disabled; nwg-panel = disabled; + opencode = enabled; waybar = { enable = false; diff --git a/homes/x86_64-linux/admin@jallen-nas/default.nix b/homes/x86_64-linux/admin@jallen-nas/default.nix index f7d480a..656ea44 100755 --- a/homes/x86_64-linux/admin@jallen-nas/default.nix +++ b/homes/x86_64-linux/admin@jallen-nas/default.nix @@ -1,10 +1,14 @@ { pkgs, config, + lib, inputs, namespace, ... }: +let + inherit (lib.${namespace}) enabled; +in { # steam-rom-manager HM module is needed for the steam-rom-manager program # options. On NixOS hosts it's provided via sharedModules; here we add it @@ -31,6 +35,7 @@ ${namespace} = { sops.enable = true; + programs.opencode = enabled; }; sops = { @@ -38,10 +43,6 @@ defaultSopsFile = "/etc/nixos/secrets/secrets.yaml"; validateSopsFiles = false; secrets = { - # NOTE: add the following key to secrets/secrets.yaml via `sops secrets/secrets.yaml` - # before deploying: hass-mcp/token: - "hass-mcp/token" = { }; - "ssh-keys-public/jallen-nas" = { path = "/home/admin/.ssh/id_ed25519.pub"; mode = "0644"; @@ -70,14 +71,6 @@ mode = "0600"; }; }; - - templates."hass-mcp.env" = { - mode = "0600"; - content = '' - HA_URL=http://nuc-nixos.local:8123 - HA_TOKEN=${config.sops.placeholder."hass-mcp/token"} - ''; - }; }; programs = { @@ -119,81 +112,5 @@ }; }; }; - - opencode = { - enable = true; - enableMcpIntegration = true; - settings = { - provider = { - nas = { - npm = "@ai-sdk/openai-compatible"; - name = "llama-server (local)"; - options = { - baseURL = "http://jallen-nas.local:8127/v1"; - }; - models = { - Qwen3-Coder-Next-Q4_0 = { - name = "Qwen3 Coder (local)"; - modalities = { - input = [ - "image" - "text" - ]; - output = [ "text" ]; - }; - limit = { - context = 262144; - output = 262144; - }; - }; - # "GLM-4.7-Flash-REAP-23B-A3B-UD-Q3_K_XL": { - # "name": "GLM 4.7 Flash (local)", - # "modalities": { "input": ["image", "text"], "output": ["text"] }, - # "limit": { - # "context": 262144, - # "output": 262144 - # } - # }; - # "Nemotron-3-Nano-30B-A3B-IQ4_XS": { - # "name": "Nemotron-3-Nano (local)", - # "modalities": { "input": ["image", "text"], "output": ["text"] }, - # "limit": { - # "context": 262144, - # "output": 262144 - # } - # }; - }; - }; - }; - }; - }; - - mcp = { - enable = true; - servers = { - nixos = { - command = "nix"; - args = [ - "run" - "github:utensils/mcp-nixos" - "--" - ]; - }; - hass-mcp = { - command = "bash"; - args = [ - "-c" - "set -a; source ${config.sops.templates."hass-mcp.env".path}; set +a; exec uvx hass-mcp" - ]; - }; - mcp-server-code-runner = { - command = "npm"; - args = [ - "-y" - "mcp-server-code-runner@latest" - ]; - }; - }; - }; }; } diff --git a/modules/home/programs/opencode/default.nix b/modules/home/programs/opencode/default.nix new file mode 100644 index 0000000..f8f1dad --- /dev/null +++ b/modules/home/programs/opencode/default.nix @@ -0,0 +1,87 @@ +{ + config, + lib, + pkgs, + namespace, + ... +}: +let + cfg = config.${namespace}.programs.opencode; +in +{ + options.${namespace}.programs.opencode = { + enable = lib.mkEnableOption "opencode"; + }; + + config = lib.mkIf cfg.enable { + sops.secrets."hass-mcp/token" = { }; + + sops.templates."hass-mcp.env" = { + mode = "0600"; + content = '' + HA_URL=http://nuc-nixos.local:8123 + HA_TOKEN=${config.sops.placeholder."hass-mcp/token"} + ''; + }; + + programs.opencode = { + enable = true; + enableMcpIntegration = true; + settings = { + provider = { + nas = { + npm = "@ai-sdk/openai-compatible"; + name = "llama-server (local)"; + options = { + baseURL = "http://jallen-nas.local:8127/v1"; + }; + models = { + Qwen3-Coder-Next-Q4_0 = { + name = "Qwen3 Coder (local)"; + modalities = { + input = [ + "image" + "text" + ]; + output = [ "text" ]; + }; + limit = { + context = 262144; + output = 262144; + }; + }; + }; + }; + }; + }; + }; + + programs.mcp = { + enable = true; + servers = { + nixos = { + command = "nix"; + args = [ + "run" + "github:utensils/mcp-nixos" + "--" + ]; + }; + hass-mcp = { + command = "bash"; + args = [ + "-c" + "set -a; source ${config.sops.templates."hass-mcp.env".path}; set +a; exec uvx hass-mcp" + ]; + }; + mcp-server-code-runner = { + command = "${pkgs.nodejs_24}/bin/npm"; + args = [ + "-y" + "mcp-server-code-runner@latest" + ]; + }; + }; + }; + }; +}