summaryrefslogtreecommitdiff
path: root/gnu/packages
diff options
context:
space:
mode:
authorDanny Milosavljevic <dannym@friendly-machines.com>2026-03-13 10:45:01 +0000
committerDanny Milosavljevic <dannym@friendly-machines.com>2026-03-14 05:01:53 +0100
commitad9ca26606c5a5c12ddf51544983dffd665846d2 (patch)
treed299f452eb49c033a52db649f100a55f3ae1ada5 /gnu/packages
parent54225ed9ea6780faf35dbb98b7d6503f7f36d5db (diff)
gnu: codex, codex-acp: Drop file_lock patches; enable network-proxy.
* gnu/packages/patches/rust-codex-0.98.0-arg0-file-lock.patch, gnu/packages/patches/rust-codex-0.98.0-core-file-lock.patch, gnu/packages/patches/rust-codex-0.98.0-execpolicy-file-lock.patch: Delete file. * gnu/local.mk (dist_patch_DATA): Unregister them. * gnu/packages/rust-sources.scm (rust-codex-0.0.0.785c0c43)[source]<patches>: Remove file-lock patches. (rust-codex-0.98.0)[source]<patches>: Likewise. [arguments]<#:cargo-package-crates>: Add codex-network-proxy. * gnu/packages/rust-apps.scm (codex)[source]<patches>: Remove file-lock patches. [arguments]<#:cargo-install-paths>: Add network-proxy. <#:cargo-package-crates>: Add codex-network-proxy. (codex-acp)[arguments]<#:rust>: Delete. <#:cargo-test-flags>: Remove override. * gnu/packages/patches/codex-0.98.0-remove-patch-sections.patch: Stop excluding network-proxy from workspace members. Change-Id: Iabc65a4ca2e8cc5801933a74a2b53b9bce404102
Diffstat (limited to 'gnu/packages')
-rw-r--r--gnu/packages/patches/codex-0.98.0-remove-patch-sections.patch16
-rw-r--r--gnu/packages/patches/rust-codex-0.98.0-arg0-file-lock.patch89
-rw-r--r--gnu/packages/patches/rust-codex-0.98.0-core-file-lock.patch91
-rw-r--r--gnu/packages/patches/rust-codex-0.98.0-execpolicy-file-lock.patch49
-rw-r--r--gnu/packages/rust-apps.scm16
-rw-r--r--gnu/packages/rust-sources.scm19
6 files changed, 12 insertions, 268 deletions
diff --git a/gnu/packages/patches/codex-0.98.0-remove-patch-sections.patch b/gnu/packages/patches/codex-0.98.0-remove-patch-sections.patch
index 34cd8bccf55..c54fe0b7fd2 100644
--- a/gnu/packages/patches/codex-0.98.0-remove-patch-sections.patch
+++ b/gnu/packages/patches/codex-0.98.0-remove-patch-sections.patch
@@ -2,28 +2,16 @@ Author: Danny Milosavljevic <dannym@friendly-machines.com>
2Date: 2026-02-08 2Date: 2026-02-08
3License: ASL2.0 3License: ASL2.0
4 4
5Remove [patch.crates-io] and [patch.'ssh://...'] sections and 5Remove [patch.crates-io] and [patch.'ssh://...'] sections.
6exclude network-proxy from workspace members.
7 6
8The [patch] sections point to git repositories which are unavailable 7The [patch] sections point to git repositories which are unavailable
9in an offline build. The vendored crossterm, ratatui, 8in an offline build. The vendored crossterm, ratatui,
10tokio-tungstenite and tungstenite forks are provided as cargo-inputs 9tokio-tungstenite and tungstenite forks are provided as cargo-inputs
11instead. 10instead.
12 11
13The network-proxy workspace member depends on rama which requires
14Rust 1.91+.
15
16--- a/codex-rs/Cargo.toml 12--- a/codex-rs/Cargo.toml
17+++ b/codex-rs/Cargo.toml 13+++ b/codex-rs/Cargo.toml
18@@ -28,7 +28,6 @@ 14@@ -311,16 +311,3 @@
19 "lmstudio",
20 "login",
21 "mcp-server",
22- "network-proxy",
23 "ollama",
24 "process-hardening",
25 "protocol",
26@@ -311,16 +310,3 @@
27 debug = 1 # Reduce debug symbol size 15 debug = 1 # Reduce debug symbol size
28 inherits = "test" 16 inherits = "test"
29 opt-level = 0 17 opt-level = 0
diff --git a/gnu/packages/patches/rust-codex-0.98.0-arg0-file-lock.patch b/gnu/packages/patches/rust-codex-0.98.0-arg0-file-lock.patch
deleted file mode 100644
index 62298d95725..00000000000
--- a/gnu/packages/patches/rust-codex-0.98.0-arg0-file-lock.patch
+++ /dev/null
@@ -1,89 +0,0 @@
1Author: Danny Milosavljevic <dannym@friendly-machines.com>
2Date: 2026-02-07
3License: ASL2.0
4Subject: Use libc::flock instead of unstable std File::try_lock().
5
6The file_lock feature is tracked at <https://github.com/rust-lang/rust/issues/130994>
7and is not yet stable in old Rust versions like Rust 1.88.
8
9diff -ruN a/codex-rs/arg0/Cargo.toml b/codex-rs/arg0/Cargo.toml
10--- a/codex-rs/arg0/Cargo.toml
11+++ b/codex-rs/arg0/Cargo.toml
12@@ -17,5 +17,6 @@
13 codex-core = { workspace = true }
14 codex-linux-sandbox = { workspace = true }
15 dotenvy = { workspace = true }
16+libc = { workspace = true }
17 tempfile = { workspace = true }
18 tokio = { workspace = true, features = ["rt-multi-thread"] }
19diff -ruN a/codex-rs/arg0/src/lib.rs b/codex-rs/arg0/src/lib.rs
20--- a/codex-rs/arg0/src/lib.rs
21+++ b/codex-rs/arg0/src/lib.rs
22@@ -5,6 +5,8 @@
23
24 use codex_core::CODEX_APPLY_PATCH_ARG1;
25 #[cfg(unix)]
26+use std::os::unix::io::AsRawFd;
27+#[cfg(unix)]
28 use std::os::unix::fs::symlink;
29 use tempfile::TempDir;
30
31@@ -13,6 +15,18 @@
32 const MISSPELLED_APPLY_PATCH_ARG0: &str = "applypatch";
33 const LOCK_FILENAME: &str = ".lock";
34
35+// FIXME: Remove this helper when Rust provides stable file locking API.
36+// The file_lock feature is tracked at <https://github.com/rust-lang/rust/issues/130994>.
37+#[cfg(unix)]
38+fn try_lock_exclusive(file: &File) -> std::io::Result<()> {
39+ let ret = unsafe { libc::flock(file.as_raw_fd(), libc::LOCK_EX | libc::LOCK_NB) };
40+ if ret == 0 {
41+ Ok(())
42+ } else {
43+ Err(std::io::Error::last_os_error())
44+ }
45+}
46+
47 /// Keeps the per-session PATH entry alive and locked for the process lifetime.
48 pub struct Arg0PathEntryGuard {
49 _temp_dir: TempDir,
50@@ -216,7 +230,7 @@
51 .create(true)
52 .truncate(false)
53 .open(&lock_path)?;
54- lock_file.try_lock()?;
55+ try_lock_exclusive(&lock_file)?;
56
57 for filename in &[
58 APPLY_PATCH_ARG0,
59@@ -307,10 +321,10 @@
60 Err(err) => return Err(err),
61 };
62
63- match lock_file.try_lock() {
64+ match try_lock_exclusive(&lock_file) {
65 Ok(()) => Ok(Some(lock_file)),
66- Err(std::fs::TryLockError::WouldBlock) => Ok(None),
67- Err(err) => Err(err.into()),
68+ Err(ref e) if e.raw_os_error() == Some(libc::EWOULDBLOCK) => Ok(None),
69+ Err(err) => Err(err),
70 }
71 }
72
73@@ -318,6 +332,7 @@
74 mod tests {
75 use super::LOCK_FILENAME;
76 use super::janitor_cleanup;
77+ use super::try_lock_exclusive;
78 use std::fs;
79 use std::fs::File;
80 use std::path::Path;
81@@ -350,7 +365,7 @@
82 let dir = root.path().join("locked");
83 fs::create_dir(&dir)?;
84 let lock_file = create_lock(&dir)?;
85- lock_file.try_lock()?;
86+ try_lock_exclusive(&lock_file)?;
87
88 janitor_cleanup(root.path())?;
89
diff --git a/gnu/packages/patches/rust-codex-0.98.0-core-file-lock.patch b/gnu/packages/patches/rust-codex-0.98.0-core-file-lock.patch
deleted file mode 100644
index ee53f7e2772..00000000000
--- a/gnu/packages/patches/rust-codex-0.98.0-core-file-lock.patch
+++ /dev/null
@@ -1,91 +0,0 @@
1Author: Danny Milosavljevic <dannym@friendly-machines.com>
2Date: 2026-01-25
3License: ASL2.0
4Subject: Use libc::flock instead of unstable std File::try_lock()/try_lock_shared().
5
6The file_lock feature is tracked at <https://github.com/rust-lang/rust/issues/130994>.
7and is not yet stable in old Rust versions like Rust 1.85.
8
9The file_lock feature was stabilized after Rust 1.88, but we only have 1.88.
10
11diff -u a/codex-rs/core/src/message_history.rs b/codex-rs/core/src/message_history.rs
12--- a/codex-rs/core/src/message_history.rs
13+++ b/codex-rs/core/src/message_history.rs
14@@ -41,6 +41,8 @@
15 use std::os::unix::fs::OpenOptionsExt;
16 #[cfg(unix)]
17 use std::os::unix::fs::PermissionsExt;
18+#[cfg(unix)]
19+use std::os::unix::io::AsRawFd;
20
21 /// Filename that stores the message history inside `~/.codex`.
22 const HISTORY_FILENAME: &str = "history.jsonl";
23@@ -51,6 +53,28 @@
24 const MAX_RETRIES: usize = 10;
25 const RETRY_SLEEP: Duration = Duration::from_millis(100);
26
27+// FIXME: Remove these helpers when Rust provides stable file locking API
28+// The file_lock feature is tracked at <https://github.com/rust-lang/rust/issues/130994>.
29+#[cfg(unix)]
30+fn try_lock_exclusive(file: &File) -> std::io::Result<()> {
31+ let ret = unsafe { libc::flock(file.as_raw_fd(), libc::LOCK_EX | libc::LOCK_NB) };
32+ if ret == 0 {
33+ Ok(())
34+ } else {
35+ Err(std::io::Error::last_os_error())
36+ }
37+}
38+
39+#[cfg(unix)]
40+fn try_lock_shared(file: &File) -> std::io::Result<()> {
41+ let ret = unsafe { libc::flock(file.as_raw_fd(), libc::LOCK_SH | libc::LOCK_NB) };
42+ if ret == 0 {
43+ Ok(())
44+ } else {
45+ Err(std::io::Error::last_os_error())
46+ }
47+}
48+
49 #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
50 pub struct HistoryEntry {
51 pub session_id: String,
52@@ -126,7 +150,7 @@
53 tokio::task::spawn_blocking(move || -> Result<()> {
54 // Retry a few times to avoid indefinite blocking when contended.
55 for _ in 0..MAX_RETRIES {
56- match history_file.try_lock() {
57+ match try_lock_exclusive(&history_file) {
58 Ok(()) => {
59 // While holding the exclusive lock, write the full line.
60 // We do not open the file with `append(true)` on Windows, so ensure the
61@@ -137,10 +161,10 @@
62 enforce_history_limit(&mut history_file, history_max_bytes)?;
63 return Ok(());
64 }
65- Err(std::fs::TryLockError::WouldBlock) => {
66+ Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => {
67 std::thread::sleep(RETRY_SLEEP);
68 }
69- Err(e) => return Err(e.into()),
70+ Err(e) => return Err(e),
71 }
72 }
73
74@@ -341,7 +365,7 @@
75 // Open & lock file for reading using a shared lock.
76 // Retry a few times to avoid indefinite blocking.
77 for _ in 0..MAX_RETRIES {
78- let lock_result = file.try_lock_shared();
79+ let lock_result = try_lock_shared(&file);
80
81 match lock_result {
82 Ok(()) => {
83@@ -368,7 +392,7 @@
84 // Not found at requested offset.
85 return None;
86 }
87- Err(std::fs::TryLockError::WouldBlock) => {
88+ Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => {
89 std::thread::sleep(RETRY_SLEEP);
90 }
91 Err(e) => {
diff --git a/gnu/packages/patches/rust-codex-0.98.0-execpolicy-file-lock.patch b/gnu/packages/patches/rust-codex-0.98.0-execpolicy-file-lock.patch
deleted file mode 100644
index 10b8b37c5c3..00000000000
--- a/gnu/packages/patches/rust-codex-0.98.0-execpolicy-file-lock.patch
+++ /dev/null
@@ -1,49 +0,0 @@
1Author: Danny Milosavljevic <dannym@friendly-machines.com>
2Date: 2026-01-25
3License: ASL2.0
4Subject: Use libc::flock instead of unstable std File::lock().
5
6The file_lock feature is tracked at <https://github.com/rust-lang/rust/issues/130994>.
7and is not yet stable in old Rust versions like Rust 1.85.
8
9The file_lock feature was stabilized after Rust 1.88, but we only have 1.88.
10
11diff -u a/codex-rs/execpolicy/Cargo.toml b/codex-rs/execpolicy/Cargo.toml
12--- a/codex-rs/execpolicy/Cargo.toml
13+++ b/codex-rs/execpolicy/Cargo.toml
14@@ -19,6 +19,7 @@
15 [dependencies]
16 anyhow = { workspace = true }
17 clap = { workspace = true, features = ["derive"] }
18+libc = { workspace = true }
19 multimap = { workspace = true }
20 serde = { workspace = true, features = ["derive"] }
21 serde_json = { workspace = true }
22diff -u a/codex-rs/execpolicy/src/amend.rs b/codex-rs/execpolicy/src/amend.rs
23--- a/codex-rs/execpolicy/src/amend.rs
24+++ b/codex-rs/execpolicy/src/amend.rs
25@@ -1,4 +1,5 @@
26 use std::fs::OpenOptions;
27+use std::os::unix::io::AsRawFd;
28 use std::io::Read;
29 use std::io::Seek;
30 use std::io::SeekFrom;
31@@ -100,10 +101,14 @@
32 path: policy_path.to_path_buf(),
33 source,
34 })?;
35- file.lock().map_err(|source| AmendError::LockPolicyFile {
36- path: policy_path.to_path_buf(),
37- source,
38- })?;
39+ // FIXME: Use file.lock() when Rust 1.91 is available
40+ let ret = unsafe { libc::flock(file.as_raw_fd(), libc::LOCK_EX) };
41+ if ret != 0 {
42+ return Err(AmendError::LockPolicyFile {
43+ path: policy_path.to_path_buf(),
44+ source: std::io::Error::last_os_error(),
45+ });
46+ }
47
48 let len = file
49 .metadata()
diff --git a/gnu/packages/rust-apps.scm b/gnu/packages/rust-apps.scm
index fadc8dfa71c..827e778c938 100644
--- a/gnu/packages/rust-apps.scm
+++ b/gnu/packages/rust-apps.scm
@@ -845,9 +845,6 @@ Commit and SemVer specifications.")
845 (origin 845 (origin
846 (inherit (package-source rust-codex-0.98.0)) 846 (inherit (package-source rust-codex-0.98.0))
847 (patches (search-patches 847 (patches (search-patches
848 "rust-codex-0.98.0-execpolicy-file-lock.patch"
849 "rust-codex-0.98.0-core-file-lock.patch"
850 "rust-codex-0.98.0-arg0-file-lock.patch"
851 "codex-0.98.0-remove-patch-sections.patch" 848 "codex-0.98.0-remove-patch-sections.patch"
852 "rust-codex-0.98.0-test-shebangs.patch" 849 "rust-codex-0.98.0-test-shebangs.patch"
853 "rust-codex-0.98.0-test-timeout.patch")))) 850 "rust-codex-0.98.0-test-timeout.patch"))))
@@ -856,7 +853,7 @@ Commit and SemVer specifications.")
856 (list 853 (list
857 #:install-source? #f 854 #:install-source? #f
858 #:cargo-install-paths '(list "cli" "exec" "exec-server" 855 #:cargo-install-paths '(list "cli" "exec" "exec-server"
859 "linux-sandbox" "mcp-server" 856 "linux-sandbox" "mcp-server" "network-proxy"
860 "app-server" "tui") 857 "app-server" "tui")
861 ;; schema_fixtures_match_generated (upstream fixture is stale: 858 ;; schema_fixtures_match_generated (upstream fixture is stale:
862 ;; FileChange::Update in codex-protocol gained old_content, 859 ;; FileChange::Update in codex-protocol gained old_content,
@@ -1042,7 +1039,7 @@ Commit and SemVer specifications.")
1042 "codex-exec" 1039 "codex-exec"
1043 "codex-exec-server" 1040 "codex-exec-server"
1044 "codex-stdio-to-uds" 1041 "codex-stdio-to-uds"
1045 ;; codex-network-proxy requires rama which needs Rust 1.91+. 1042 "codex-network-proxy"
1046 "codex-chatgpt" 1043 "codex-chatgpt"
1047 "codex-cloud-tasks-client" 1044 "codex-cloud-tasks-client"
1048 ;;; Tier 5. 1045 ;;; Tier 5.
@@ -1148,7 +1145,10 @@ Commit and SemVer specifications.")
1148 (lambda _ 1145 (lambda _
1149 (setenv "HOME" "/tmp") 1146 (setenv "HOME" "/tmp")
1150 (setenv "USER" "nixbld")))))) 1147 (setenv "USER" "nixbld"))))))
1151 (native-inputs (list perl python-minimal ;for tests 1148 (native-inputs (list clang ;bindgen uses libclang to parse BoringSSL's C headers
1149 cmake-minimal ;BoringSSL is compiled from C source
1150 libunwind ;BoringSSL tests verify stack unwinding in assembly
1151 perl python-minimal ;for tests
1152 pkg-config)) 1152 pkg-config))
1153 (inputs (cons* bash-minimal coreutils git-minimal sed 1153 (inputs (cons* bash-minimal coreutils git-minimal sed
1154 openssl sqlite `(,zstd "lib") 1154 openssl sqlite `(,zstd "lib")
@@ -1180,11 +1180,7 @@ Configure providers via @file{~/.codex/config.toml}.")
1180 (build-system cargo-build-system) 1180 (build-system cargo-build-system)
1181 (arguments 1181 (arguments
1182 (list 1182 (list
1183 #:rust rust-1.88
1184 #:install-source? #f 1183 #:install-source? #f
1185 ;; Skip doctests (--doc) because rustdoc is unavailable for non-default
1186 ;; Rust versions in Guix.
1187 #:cargo-test-flags '(list "--lib" "--bins" "--tests")
1188 #:phases 1184 #:phases
1189 #~(modify-phases %standard-phases 1185 #~(modify-phases %standard-phases
1190 (add-after 'unpack 'patch-codex-deps 1186 (add-after 'unpack 'patch-codex-deps
diff --git a/gnu/packages/rust-sources.scm b/gnu/packages/rust-sources.scm
index c4e2c2685d2..93ddee042a4 100644
--- a/gnu/packages/rust-sources.scm
+++ b/gnu/packages/rust-sources.scm
@@ -728,13 +728,7 @@ intelligence.")
728 (file-name (git-file-name name version)) 728 (file-name (git-file-name name version))
729 (sha256 729 (sha256
730 (base32 "0rwj1ykknng39mhzna3fw3rcl3vngynsjdcj1namgkvw91zd9dl7")) 730 (base32 "0rwj1ykknng39mhzna3fw3rcl3vngynsjdcj1namgkvw91zd9dl7"))
731 ;; TODO: Remove patches when Rust provides stable file locking API. 731 (patches (search-patches "rust-codex-0.98.0-core-remove-self-dep.patch"))))
732 ;; The file_lock feature is tracked at
733 ;; <https://github.com/rust-lang/rust/issues/130994>.
734 (patches (search-patches "rust-codex-0.98.0-execpolicy-file-lock.patch"
735 "rust-codex-0.98.0-core-file-lock.patch"
736 "rust-codex-0.98.0-arg0-file-lock.patch"
737 "rust-codex-0.98.0-core-remove-self-dep.patch"))))
738 (build-system cargo-build-system) 732 (build-system cargo-build-system)
739 (arguments 733 (arguments
740 (list 734 (list
@@ -832,9 +826,6 @@ and runtime for AI-assisted coding.")
832 (file-name (git-file-name name version)) 826 (file-name (git-file-name name version))
833 (sha256 827 (sha256
834 (base32 "1mn322gbir4gn4y5jihdqg0wprjlnx771chyfmmm7ri7pnim1zmc")) 828 (base32 "1mn322gbir4gn4y5jihdqg0wprjlnx771chyfmmm7ri7pnim1zmc"))
835 ;; TODO: Remove patches when Rust provides stable file locking API.
836 ;; The file_lock feature is tracked at
837 ;; <https://github.com/rust-lang/rust/issues/130994>.
838 (modules '((guix build utils))) 829 (modules '((guix build utils)))
839 (snippet '(begin 830 (snippet '(begin
840 ;;; These are JSON manifests with a dotslash 831 ;;; These are JSON manifests with a dotslash
@@ -845,10 +836,7 @@ and runtime for AI-assisted coding.")
845 ;; Bundled bubblewrap source tree; includes a 836 ;; Bundled bubblewrap source tree; includes a
846 ;; compiled BPF blob (demos/flatpak.bpf). 837 ;; compiled BPF blob (demos/flatpak.bpf).
847 (delete-file-recursively "codex-rs/vendor/bubblewrap"))) 838 (delete-file-recursively "codex-rs/vendor/bubblewrap")))
848 (patches (search-patches "rust-codex-0.98.0-execpolicy-file-lock.patch" 839 (patches (search-patches "rust-codex-0.98.0-core-remove-self-dep.patch"
849 "rust-codex-0.98.0-core-file-lock.patch"
850 "rust-codex-0.98.0-arg0-file-lock.patch"
851 "rust-codex-0.98.0-core-remove-self-dep.patch"
852 "rust-codex-0.98.0-windows-sandbox-protocol-version.patch" 840 "rust-codex-0.98.0-windows-sandbox-protocol-version.patch"
853 "rust-codex-0.98.0-test-shebangs.patch")))) 841 "rust-codex-0.98.0-test-shebangs.patch"))))
854 (build-system cargo-build-system) 842 (build-system cargo-build-system)
@@ -888,7 +876,8 @@ and runtime for AI-assisted coding.")
888 "codex-login" ; Depends on codex-core 876 "codex-login" ; Depends on codex-core
889 "codex-ollama" ; Depends on codex-core 877 "codex-ollama" ; Depends on codex-core
890 "codex-common" ; Depends on codex-core, codex-lmstudio, codex-ollama 878 "codex-common" ; Depends on codex-core, codex-lmstudio, codex-ollama
891 "codex-mcp-server") ; Depends on codex-core, codex-common 879 "codex-mcp-server" ; Depends on codex-core, codex-common
880 "codex-network-proxy") ; Depends on codex-core, rama
892 #:phases 881 #:phases
893 #~(modify-phases %standard-phases 882 #~(modify-phases %standard-phases
894 (add-after 'unpack 'chdir-to-workspace 883 (add-after 'unpack 'chdir-to-workspace