--- /dev/null
+;; 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)))