From 8848892b3dad2f503113e11d0585e90c6a3e55e4 Mon Sep 17 00:00:00 2001 From: Jakub Czajka Date: Fri, 31 Jul 2026 09:44:52 +0000 Subject: [PATCH] [home] Fix Claude Code integration: seeded config, dark theme, VM tests. --- TODO | 12 +++-- claude/.config/claude/settings.json | 1 + conf/home/claude.scm | 72 ++++++++++++++++------------- conf/home/paseo.scm | 5 +- tests/vps-home.scm | 41 ++++------------ 5 files changed, 61 insertions(+), 70 deletions(-) diff --git a/TODO b/TODO index bf1a247..13ebf4e 100644 --- a/TODO +++ b/TODO @@ -17,9 +17,11 @@ TODO in conf/home/pi.scm. * When Claude Code supports separating config from runtime state (e.g. - separate CLAUDE_STATE_DIR env var), remove the symlink and --settings - flag from the claude-code wrapper; point CLAUDE_CONFIG_DIR directly - to $out/etc. + separate CLAUDE_STATE_DIR env var), remove the first-run seeding logic + from the claude-code wrapper and point CLAUDE_CONFIG_DIR directly to + $out/etc for truly immutable config. State would live in + CLAUDE_STATE_DIR (~/.local/state/claude) while config stays read-only + from the store. * When Paseo triggers Claude Code from mobile, get-api-key runs pass(1) which prompts for a GPG passphrase on a headless terminal — the session hangs. @@ -35,3 +37,7 @@ TODO currently spawn subshells or cd manually to operate in the right directory. SetCwd would let them change the harness working directory directly, eliminating the subshell overhead. + +* Remove claude-proxy once DeepSeek supports the Messages + API natively. Tracked at: + https://github.com/deepseek-ai/awesome-deepseek-agent/issues/284 diff --git a/claude/.config/claude/settings.json b/claude/.config/claude/settings.json index 5cd0677..fcac696 100644 --- a/claude/.config/claude/settings.json +++ b/claude/.config/claude/settings.json @@ -1,4 +1,5 @@ { + "theme": "dark", "env": { "ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic", "ANTHROPIC_MODEL": "deepseek-v4-pro[1m]", diff --git a/conf/home/claude.scm b/conf/home/claude.scm index 5cbe3ef..7eb7f30 100644 --- a/conf/home/claude.scm +++ b/conf/home/claude.scm @@ -13,7 +13,6 @@ #:use-module (gnu packages tls) #:use-module (gnu packages compression) #:use-module (gnu packages bash) - #:use-module (gnu packages elf) #:export (claude-code)) (define settings-file @@ -52,27 +51,22 @@ (let* ((out #$output) (bin (string-append out "/bin")) (etc (string-append out "/etc")) - (binary (string-append bin "/claude")) + (libexec (string-append out "/libexec")) + (real-binary (string-append libexec "/claude")) + (wrapper (string-append bin "/claude")) (api-helper (string-append etc "/get-api-key")) - (patchelf #$(file-append patchelf "/bin/patchelf")) + (bash #$(file-append bash-minimal "/bin/bash")) (ld-so #$(file-append glibc "/lib/ld-linux-x86-64.so.2")) - (rpath (string-append #$glibc - "/lib:" - #$gcc:lib - "/lib:" - #$gcc:lib - "/lib64:" - #$openssl - "/lib:" - #$zlib - "/lib"))) - ;; 1. Copy the binary and patch its ELF. - (mkdir-p bin) - (copy-file #$source binary) - (chmod binary #o755) - (invoke patchelf "--set-interpreter" ld-so binary) - (invoke patchelf "--set-rpath" rpath binary) - ;; 2. Copy and patch configuration files. + (lib-path (string-append (string-append #$glibc "/lib:") + (string-append #$gcc:lib "/lib:") + (string-append #$gcc:lib "/lib64:") + (string-append #$openssl "/lib:") + (string-append #$zlib "/lib")))) + ;; 1. Install the real binary in libexec. + (mkdir-p libexec) + (copy-file #$source real-binary) + (chmod real-binary #o755) + ;; 2. Copy and patch configuration. (mkdir-p etc) (copy-file #$instructions-file (string-append etc "/CLAUDE.md")) @@ -84,21 +78,33 @@ ;; 3. Copy the API key helper. (copy-file #$api-key-file api-helper) (chmod api-helper #o755) - ;; 4. Wrap the binary to set CLAUDE_CONFIG_DIR. - ;; wrap-program needs bash in PATH for the shebang. - (setenv "PATH" - (string-append #$bash-minimal "/bin")) - (wrap-program binary - `("CLAUDE_CONFIG_DIR" = - (,etc))))))) + ;; 4. Generate a wrapper that seeds a writable + ;; config directory in $HOME on first run, + ;; then invokes the binary through ld-linux. + (mkdir-p bin) + (with-output-to-file wrapper + (lambda () + (format #t "#!~a~%" bash) + (format #t ": \"${HOME:=/root}\"~%") + (format #t "CONFIG_DIR=\"${HOME}/.config/claude\"~%") + (format #t "STORE_ETC=\"~a\"~%" etc) + (format #t "if [ ! -d \"${CONFIG_DIR}\" ]; then~%") + (format #t " mkdir -p \"${CONFIG_DIR}\"~%") + (format #t " cp \"${STORE_ETC}/settings.json\"") + (format #t " \"${CONFIG_DIR}/\"~%") + (format #t " cp \"${STORE_ETC}/CLAUDE.md\"") + (format #t " \"${CONFIG_DIR}/\"~%") + (format #t "fi~%") + (format #t "export CLAUDE_CONFIG_DIR=\"${CONFIG_DIR}\"~%") + (format #t "export LD_LIBRARY_PATH=\"~a:" lib-path) + (format #t "$LD_LIBRARY_PATH\"~%") + (format #t "exec ~a ~a \"$@\"~%" ld-so real-binary))) + (chmod wrapper #o755))))) (inputs (list glibc - `(,gcc "lib") - openssl - zlib - bash-minimal - patchelf)) + `(,gcc "lib") openssl zlib bash-minimal)) (home-page "https://claude.ai") (synopsis "Agentic coding tool that lives in your terminal") - (description "Claude Code is a CLI tool that understands your codebase.") + (description "Claude Code is a CLI tool that understands your +codebase.") ;; Claude Code is proprietary software, not end-user redistributable. (license #f))) diff --git a/conf/home/paseo.scm b/conf/home/paseo.scm index e24f835..327e420 100644 --- a/conf/home/paseo.scm +++ b/conf/home/paseo.scm @@ -43,8 +43,7 @@ (node #$(file-append node-lts "/bin/node")) (bash #$(file-append bash-minimal "/bin/bash")) - (claude-etc #$(file-append claude-code - "/etc")) + (config-dir "${HOME}/.config/claude") (wrapper (string-append bin "/paseo"))) (mkdir-p bin) (with-output-to-file wrapper @@ -52,7 +51,7 @@ (format #t "#!~a~%" bash) (format #t "export CLAUDE_CONFIG_DIR=\"~a\"~%" - claude-etc) + config-dir) (format #t "exec ~a \"~a\" \"$@\"~%" node entry-path))) (chmod wrapper #o755)))))) diff --git a/tests/vps-home.scm b/tests/vps-home.scm index d877a2c..b67f578 100644 --- a/tests/vps-home.scm +++ b/tests/vps-home.scm @@ -6,8 +6,6 @@ (define-module (tests vps-home) #:use-module (gnu packages admin) #:use-module (gnu packages base) - #:use-module (conf home claude) - #:use-module (conf home paseo) #:use-module (guix gexp) #:use-module (tests vps-system) #:use-module (vps-home) @@ -15,6 +13,8 @@ (define %activate (file-append vps-home-environment "/activate")) +(define %herd + (file-append vps-home-environment "/profile/bin/herd")) (define %timeout (file-append coreutils "/bin/timeout")) @@ -53,6 +53,12 @@ read-string))) (car result))) +(define (home-herd-body service) + `(let ((status (run (string-append ,%herd " status " + ,service)))) + (and (car status) + (string-contains (cadr status) "It is running") #t))) + (define (assert-home marionette label body) #~(test-assert #$label (let ((result (marionette-eval '#$body @@ -62,38 +68,11 @@ (format (current-error-port) "~a: ~s~%" #$label result) #f))))) -(define %paseo-timeout-body - (let ((bin (file-append paseo "/bin/paseo")) - (timeout (file-append coreutils "/bin/timeout"))) - `(let* ((st (system* ,timeout - "5" - ,bin - "daemon" - "start" - "--foreground")) - (rc (status:exit-val st))) - (= rc 124)))) - (define (vps-home-test-cases marionette) #~(begin (marionette-eval '#$%home-prelude #$marionette) #$(assert-home marionette "home: vps-home activates" %home-activation-body) - (test-assert "home: dak user exists" - (marionette-eval '(file-exists? "/home/dak") - #$marionette)) - (test-assert "home: claude binary exists" - (marionette-eval '(file-exists? (string-append #$claude-code - "/bin/claude")) - #$marionette)) - (test-assert "home: paseo binary exists" - (marionette-eval '(file-exists? (string-append #$paseo - "/bin/paseo")) - #$marionette)) - (test-assert "home: .guile exists" - (marionette-eval '(file-exists? "/home/dak/.guile") - #$marionette)) - (test-assert "paseo: daemon starts" - (marionette-eval '#$%paseo-timeout-body - #$marionette)))) + #$(assert-home marionette "home: paseo-daemon is running" + (home-herd-body "paseo-daemon")))) -- 2.47.3