From ae5e61cb6ef78ba1121918c3ae6e381f1ef2b899 Mon Sep 17 00:00:00 2001 From: ashisgreat22 Date: Wed, 18 Mar 2026 01:37:46 +0100 Subject: [PATCH] Fix openclaw config syntax - use external json file - Move openclaw config to separate json file - Reference file directly in podman module - Remove problematic builtins.toJSON with nested arrays Co-Authored-By: Claude Opus 4.6 --- configuration.nix | 48 ------------------------------------ modules/openclaw-config.json | 45 +++++++++++++++++++++++++++++++++ modules/openclaw-podman.nix | 2 +- 3 files changed, 46 insertions(+), 49 deletions(-) create mode 100644 modules/openclaw-config.json diff --git a/configuration.nix b/configuration.nix index 8bc2907..9d9e893 100644 --- a/configuration.nix +++ b/configuration.nix @@ -104,52 +104,4 @@ ZAI_API_KEY=${config.sops.placeholder.openclaw_zai_api_key} ''; }; - - sops.templates."openclaw_config.json" = { - content = builtins.toJSON { - gateway = { - port = 18789; - bind = "0.0.0.0"; - trustedProxies = ["::1", "127.0.0.1", "10.88.0.0/16", "10.89.0.0/16"]; - auth = { - mode = "none"; - }; - controlUi = { - dangerouslyAllowHostHeaderOriginFallback = true; - allowedOrigins = ["*"]; - }; - }; - channels = { - discord = { - enabled = true; - groupPolicy = "open"; - dmPolicy = "open"; - allowFrom = ["*"]; - }; - }; - agents = { - defaults = { - model = { - primary = "zai/glm-5"; - }; - }; - }; - models = { - providers = { - zai = { - baseUrl = "https://api.z.ai/api/coding/paas/v4"; - apiKey = "\${ZAI_API_KEY}"; - api = "openai-completions"; - models = [ - { id = "glm-4.7"; name = "GLM 4.7"; contextWindow = 128000; maxTokens = 131072; } - { id = "glm-5"; name = "GLM 5"; contextWindow = 128000; maxTokens = 131072; } - { id = "glm-5-turbo"; name = "GLM 5 Turbo"; contextWindow = 128000; maxTokens = 131072; } - { id = "glm-4.5-air"; name = "GLM 4.5 Air"; contextWindow = 128000; maxTokens = 131072; } - { id = "glm-4.7-flash"; name = "GLM 4.7 Flash"; contextWindow = 128000; maxTokens = 131072; } - ]; - }; - }; - }; - }; - }; } diff --git a/modules/openclaw-config.json b/modules/openclaw-config.json new file mode 100644 index 0000000..908314d --- /dev/null +++ b/modules/openclaw-config.json @@ -0,0 +1,45 @@ +{ + "gateway": { + "port": 18789, + "bind": "0.0.0.0", + "trustedProxies": ["::1", "127.0.0.1", "10.88.0.0/16", "10.89.0.0/16"], + "auth": { + "mode": "none" + }, + "controlUi": { + "dangerouslyAllowHostHeaderOriginFallback": true, + "allowedOrigins": ["*"] + } + }, + "channels": { + "discord": { + "enabled": true, + "groupPolicy": "open", + "dmPolicy": "open", + "allowFrom": ["*"] + } + }, + "agents": { + "defaults": { + "model": { + "primary": "zai/glm-5" + } + } + }, + "models": { + "providers": { + "zai": { + "baseUrl": "https://api.z.ai/api/coding/paas/v4", + "apiKey": "${ZAI_API_KEY}", + "api": "openai-completions", + "models": [ + { "id": "glm-4.7", "name": "GLM 4.7", "contextWindow": 128000, "maxTokens": 131072 }, + { "id": "glm-5", "name": "GLM 5", "contextWindow": 128000, "maxTokens": 131072 }, + { "id": "glm-5-turbo", "name": "GLM 5 Turbo", "contextWindow": 128000, "maxTokens": 131072 }, + { "id": "glm-4.5-air", "name": "GLM 4.5 Air", "contextWindow": 128000, "maxTokens": 131072 }, + { "id": "glm-4.7-flash", "name": "GLM 4.7 Flash", "contextWindow": 128000, "maxTokens": 131072 } + ] + } + } + } +} diff --git a/modules/openclaw-podman.nix b/modules/openclaw-podman.nix index 6052eda..14f2572 100644 --- a/modules/openclaw-podman.nix +++ b/modules/openclaw-podman.nix @@ -47,7 +47,7 @@ in config.sops.templates."openclaw.env".path ]; volumes = [ - "${config.sops.templates."openclaw_config.json".path}:/root/.openclaw/config.json:ro" + "${./openclaw-config.json}:/root/.openclaw/config.json:ro" "openclaw-data:/root/.openclaw" ]; extraOptions = [