]> git.ekhem.eu.org Git - guix.git/commitdiff
[home] Install Claude Code.
authorJakub Czajka <jakub@ekhem.eu.org>
Sat, 20 Jun 2026 21:40:24 +0000 (23:40 +0200)
committerJakub Czajka <jakub@ekhem.eu.org>
Wed, 24 Jun 2026 22:53:15 +0000 (00:53 +0200)
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 <noreply@anthropic.com>
README
bash/.config/profile.d/20-env.sh
conf/home/claude-code.scm [new file with mode: 0644]
home.scm

diff --git a/README b/README
index db3d3f88c9c3ffd7be66eff5d3fb3c05e9bd83bc..02dc15cddf39e10308b1b55eee31ae757b302a71 100644 (file)
--- a/README
+++ b/README
@@ -26,3 +26,13 @@ Files
 * conf/common/ - custom GNU Guix programs and services shared by home and system
                  configurations.
 * <program>/   - 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.
index 07ae4e22ae9e60e9e349f0942526770d760530eb..1ad317f0106d528b4f0ff3e18f1bf583bb71c81b 100644 (file)
@@ -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 (file)
index 0000000..edcac1b
--- /dev/null
@@ -0,0 +1,80 @@
+;; Copyright (c) 2026 Jakub Czajka <jakub@ekhem.eu.org>
+;; 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)))
index 8cedf9096a458c40bc46e939d6a28487851dbb2f..ddc4b94e0027368385c252fa26c57bb4ca7b1938 100644 (file)
--- 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