From de10366ec8a386a076705e058ed13646b63e8c5c Mon Sep 17 00:00:00 2001 From: Jakub Czajka Date: Sat, 20 Jun 2026 23:40:24 +0200 Subject: [PATCH] [home] Install Claude Code. Introduce a Guix package for the upstream Claude Code binary. The binary is prebuilt for FHS systems, so wrap it in a shell script that sets LD_LIBRARY_PATH to Guix store paths and invokes it via ld-linux. Set CLAUDE_CONFIG_DIR to store its configuration under ~/.config/claude instead of ~/.claude. Document manual version-update instructions in the README. Co-Authored-By: Claude Opus 4.8 --- README | 10 ++++ bash/.config/profile.d/20-env.sh | 1 + conf/home/claude-code.scm | 80 ++++++++++++++++++++++++++++++++ home.scm | 3 +- 4 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 conf/home/claude-code.scm diff --git a/README b/README index db3d3f8..02dc15c 100644 --- a/README +++ b/README @@ -26,3 +26,13 @@ Files * conf/common/ - custom GNU Guix programs and services shared by home and system configurations. * / - program-specific dotfiles. + +TODO +---- + +* Automatically update the version of Claude Code in conf/home/claude-code.scm. + + 1. Latest version at https://downloads.claude.ai/claude-code-releases/. + 2. Update the version field in conf/home/claude-code.scm. + 3. Add claude-code at the end, run guix build -f conf/home/claude-code.scm and + get the correct hash from the "hash mismatch" error message. diff --git a/bash/.config/profile.d/20-env.sh b/bash/.config/profile.d/20-env.sh index 07ae4e2..1ad317f 100644 --- a/bash/.config/profile.d/20-env.sh +++ b/bash/.config/profile.d/20-env.sh @@ -7,3 +7,4 @@ export EDITOR="emacs" export DISPLAY=":1" export PATH="${HOME}/.local/bin:${PATH}" export TERM="st-256color" +export CLAUDE_CONFIG_DIR="${HOME}/.config/claude" diff --git a/conf/home/claude-code.scm b/conf/home/claude-code.scm new file mode 100644 index 0000000..edcac1b --- /dev/null +++ b/conf/home/claude-code.scm @@ -0,0 +1,80 @@ +;; Copyright (c) 2026 Jakub Czajka +;; License: GPL-3.0 or later. +;; +;; claude-code.scm - package definition for Claude Code. +;; +;; The upstream binary is prebuilt for systems with Filesystem Hierarchy +;; Standard and expects a standard linker path. GNU Guix uses non-standard store +;; paths, so we wrap the binary in a shell script that sets LD_LIBRARY_PATH to +;; the store locations of its dependencies and invokes it through ld-linux. + +(define-module (conf home claude-code) + #:use-module (guix packages) + #:use-module (guix download) + #:use-module (guix gexp) + #:use-module (guix build-system trivial) + #:use-module (gnu packages base) + #:use-module (gnu packages gcc) + #:use-module (gnu packages tls) + #:use-module (gnu packages compression) + #:use-module (gnu packages bash) + #:export (claude-code)) + +(define claude-code + (package + (name "claude-code") + (version "2.1.185") + (source + (origin + (method url-fetch) + (uri (string-append "https://downloads.claude.ai/claude-code-releases/" + version "/linux-x64/claude")) + (sha256 + (base32 "0lir62y47bbdkkkbs505issbm86p9rnkzvkxc87fw14zd4w66971")))) + (build-system trivial-build-system) + (arguments + (list + #:modules '((guix build utils)) + #:builder + #~(begin + (use-modules (guix build utils)) + (let* ((out #$output) + (bin (string-append out "/bin")) + (internal-bin (string-append out "/libexec")) + (real-binary (string-append internal-bin "/claude")) + (wrapper (string-append bin "/claude")) + (bash (string-append #$bash-minimal "/bin/bash")) + (ld-linux (string-append #$glibc "/lib/ld-linux-x86-64.so.2")) + ;; Define runtime library path for the wrapper. + (lib-path (string-append #$glibc + "/lib:" + #$gcc:lib + "/lib:" + #$gcc:lib + "/lib64:" + #$openssl + "/lib:" + #$zlib + "/lib"))) + ;; 1. Copy the raw binary into an isolated internal path. + (mkdir-p internal-bin) + (copy-file #$source real-binary) + (chmod real-binary #o755) + ;; 2. Generate a shell wrapper that invokes the binary + ;; using Guix's linker. + (mkdir-p bin) + (with-output-to-file wrapper + (lambda () + (format #t "#!~a~%" bash) + (format #t "export LD_LIBRARY_PATH=\"~a:" lib-path) + (format #t "$LD_LIBRARY_PATH\"~%") + ;; Invoke the explicit linker, passing CLI args. + (format #t "exec ~a ~a \"$@\"~%" ld-linux real-binary))) + (chmod wrapper #o755))))) + (inputs (list glibc + `(,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.") + ;; Claude Code is proprietary software, not end-user redistributable. + (license #f))) diff --git a/home.scm b/home.scm index 8cedf90..ddc4b94 100644 --- a/home.scm +++ b/home.scm @@ -9,6 +9,7 @@ (use-modules (gnu home) (conf home bash) + (conf home claude-code) (conf home emoji) (conf home desktop) (conf home emacs) @@ -22,7 +23,7 @@ (home-environment (packages (case profile ((nonfree) - (list firefox select-emoji st-libxft-bgra)) + (list claude-code firefox select-emoji st-libxft-bgra)) ((libre) (list icecat-minimal select-emoji st-libxft-bgra)))) (services -- 2.47.3