projects/guix·blob master · refs

127 lines · 5.2 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2026 Danny Milosavljevic <[email protected]>
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19;;; This module is separate from (gnu packages rust-apps) to avoid a
20;;; circular module dependency: (gnu packages rust-sources), which
21;;; defines rust-codex packages used by codex-acp, transitively loads
22;;; (gnu packages rust-apps) through its #:use-module chain. If the
23;;; codex-acp package lived in rust-apps.scm, loading rust-sources would
24;;; trigger loading rust-apps before those rust-codex packages are
25;;; defined, causing an unbound variable error.
26
27(define-module (gnu packages codex)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (guix gexp)
30 #:use-module (guix packages)
31 #:use-module (guix download)
32 #:use-module (guix git-download)
33 #:use-module (guix search-paths)
34 #:use-module (guix utils)
35 #:use-module (guix build-system cargo)
36 #:use-module (srfi srfi-1)
37 #:use-module (gnu packages)
38 #:use-module (gnu packages bash)
39 #:use-module (gnu packages base)
40 #:use-module (gnu packages cmake)
41 #:use-module (gnu packages compression)
42 #:use-module (gnu packages curl)
43 #:use-module (gnu packages gdb)
44 #:use-module (gnu packages linux)
45 #:use-module (gnu packages libunwind)
46 #:use-module (gnu packages llvm)
47 #:use-module (gnu packages llvm-meta)
48 #:use-module (gnu packages lsof)
49 #:use-module (gnu packages perl)
50 #:use-module (gnu packages pkg-config)
51 #:use-module (gnu packages python)
52 #:use-module (gnu packages regex)
53 #:use-module (gnu packages rust)
54 #:use-module (gnu packages rust-sources)
55 #:use-module (gnu packages sqlite)
56 #:use-module (gnu packages nss)
57 #:use-module (gnu packages tls)
58 #:use-module (gnu packages version-control)
59 #:use-module (gnu packages virtualization))
60
61(define-public codex-acp
62 (package
63 (name "codex-acp")
64 (version "0.11.1")
65 (source
66 (origin
67 (method git-fetch)
68 (uri (git-reference
69 (url "https://github.com/zed-industries/codex-acp")
70 (commit (string-append "v" version))))
71 (file-name (git-file-name name version))
72 (sha256
73 (base32 "1rlgkbvrbdl5jhf49sjn2mifn2rq6z0vwf0gard23y1bz6sr3wmr"))
74 (patches (search-patches "codex-acp-0.11.1-remove-patch-sections.patch"))))
75 (build-system cargo-build-system)
76 (arguments
77 (list
78 #:install-source? #f
79 #:phases
80 #~(modify-phases %standard-phases
81 (add-after 'unpack 'patch-codex-deps
82 (lambda* (#:key inputs #:allow-other-keys)
83 ;; Rewrite git dependencies to use vendored sources from rust-codex
84 (substitute* "Cargo.toml"
85 (("git = \"https://github.com/openai/codex\", tag = \"rust-v0.117.0\"")
86 "version = \"0.117.0\""))
87 ;; Disable V8 runtime in codex-code-mode (transitive dep).
88 (let ((port (open-file "Cargo.toml" "a")))
89 (display "
90[dependencies.codex-code-mode]
91version = \"0.117.0\"
92default-features = false
93" port)
94 (close-port port))
95 ;; Point codex-linux-sandbox at system bubblewrap source.
96 (setenv "CODEX_BWRAP_SOURCE_DIR"
97 (string-append
98 (assoc-ref inputs "bubblewrap-source")
99 "/"))))
100 (add-before 'check 'set-home
101 (lambda _
102 (setenv "HOME" "/tmp")
103 (setenv "USER" "nixbld")))
104 (add-before 'build 'create-node-version-file
105 (lambda _
106 ;; codex-core's js_repl uses include_str! to read
107 ;; node-version.txt four directories up from its source;
108 ;; create it where the vendored crate expects it.
109 (call-with-output-file "guix-vendor/node-version.txt"
110 (lambda (port)
111 (display "22.22.0" port))))))))
112 (native-inputs
113 `(("cmake-minimal" ,cmake-minimal)
114 ("clang" ,clang)
115 ("pkg-config" ,pkg-config)
116 ("bubblewrap-source" ,(package-source bubblewrap))))
117 (inputs (cons* libcap openssl sqlite zlib `(,zstd "lib")
118 (cargo-inputs 'codex-acp)))
119 (home-page "https://github.com/zed-industries/codex-acp")
120 (synopsis "ACP-compatible agent bridging Zed Codex with ACP clients")
121 (description
122 "This package provides an Agent Client Protocol (ACP) compatible agent
123that bridges the Zed Codex runtime with ACP clients over stdio. It
124supports multiple LLM providers through configuration in
125@file{~/.codex/config.toml} and integrates with MCP servers for filesystem
126operations.")
127 (license license:asl2.0)))