From 9dc29832c4fc17cd93f6eca6c0556277690a0061 Mon Sep 17 00:00:00 2001 From: polwex Date: Sun, 27 Jul 2025 04:21:58 +0700 Subject: m --- derivations/codex/default.nix | 63 ------------------------------------------- derivations/codex/flake.lock | 27 +++++++++++++++++++ derivations/codex/flake.nix | 10 +++++-- derivations/codex/node.nix | 59 ++++++++++++++++++++++++++++++++++++++++ derivations/codex/rust.nix | 63 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 157 insertions(+), 65 deletions(-) delete mode 100644 derivations/codex/default.nix create mode 100644 derivations/codex/flake.lock create mode 100644 derivations/codex/node.nix create mode 100644 derivations/codex/rust.nix (limited to 'derivations/codex') diff --git a/derivations/codex/default.nix b/derivations/codex/default.nix deleted file mode 100644 index 5a0f366..0000000 --- a/derivations/codex/default.nix +++ /dev/null @@ -1,63 +0,0 @@ -{ - lib, - rustPlatform, - fetchFromGitHub, - nix-update-script, - pkg-config, - openssl, - versionCheckHook, -}: -rustPlatform.buildRustPackage (finalAttrs: { - pname = "codex"; - version = "0.7.0"; - - src = fetchFromGitHub { - owner = "openai"; - repo = "codex"; - rev = "f14b5adabf5db34864c44c1ffc6c566b018fe0cc"; - # tag = "rust-v${finalAttrs.version}"; - hash = "sha256-rRe0JFEO5ixxrZYDL8kxXDOH0n7lqabkXNNaSlNnQDg="; - }; - - sourceRoot = "${finalAttrs.src.name}/codex-rs"; - - useFetchCargoVendor = true; - cargoHash = "sha256-QIZ3V4NUo1VxJN3cwdQf3S0zwePnwdKKfch0jlIJacU="; - - nativeBuildInputs = [ - pkg-config - ]; - buildInputs = [ - openssl - ]; - - checkFlags = [ - "--skip=keeps_previous_response_id_between_tasks" # Requires network access - "--skip=retries_on_early_close" # Requires network access - ]; - - doInstallCheck = true; - nativeInstallCheckInputs = [versionCheckHook]; - - passthru = { - updateScript = nix-update-script { - extraArgs = [ - "--version-regex" - "^rust-v(\\d+\\.\\d+\\.\\d+)$" - ]; - }; - }; - - meta = { - description = "Lightweight coding agent that runs in your terminal"; - homepage = "https://github.com/openai/codex"; - changelog = "https://raw.githubusercontent.com/openai/codex/refs/tags/rust-v${finalAttrs.version}/CHANGELOG.md"; - license = lib.licenses.asl20; - mainProgram = "codex"; - maintainers = with lib.maintainers; [ - malo - delafthi - ]; - platforms = lib.platforms.unix; - }; -}) diff --git a/derivations/codex/flake.lock b/derivations/codex/flake.lock new file mode 100644 index 0000000..05b1cf8 --- /dev/null +++ b/derivations/codex/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1752480373, + "narHash": "sha256-JHQbm+OcGp32wAsXTE/FLYGNpb+4GLi5oTvCxwSoBOA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "62e0f05ede1da0d54515d4ea8ce9c733f12d9f08", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/derivations/codex/flake.nix b/derivations/codex/flake.nix index 3a0a46f..38ad305 100644 --- a/derivations/codex/flake.nix +++ b/derivations/codex/flake.nix @@ -12,8 +12,14 @@ system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; in { - packages.${system}.default = pkgs.callPackage ./default.nix { - inherit (pkgs) lib buildNpmPackage fetchFromGitHub fetchNpmDeps gitUpdater; + packages.${system}.rust = pkgs.callPackage ./rust.nix { + inherit (pkgs) lib rustPlatform fetchFromGitHub nix-update-script pkg-config openssl versionCheckHook; + }; + packages.${system}.node = pkgs.callPackage ./node.nix { + inherit (pkgs) lib fetchFromGitHub jq makeWrapper; + node = pkgs.nodejs_22; + pnpm = pkgs.pnpm_10; + mkDerivation = pkgs.stdenv.mkDerivation; }; }; } diff --git a/derivations/codex/node.nix b/derivations/codex/node.nix new file mode 100644 index 0000000..7cf50d5 --- /dev/null +++ b/derivations/codex/node.nix @@ -0,0 +1,59 @@ +{ + lib, + mkDerivation, + fetchFromGitHub, + pnpm, + node, + jq, + makeWrapper, +}: +mkDerivation (finalAttrs: { + pname = "codex-cli"; + version = "0.8.0"; + src = fetchFromGitHub { + owner = "openai"; + repo = "codex"; + rev = "4082246f6aac288a817330b92cfd5573df61f0e7"; + # tag = "v${finalAttrs.version}"; + sha256 = "DAenod/w9BydYdYsOnuLj7kCQRcTnZ81tf4MhLUug6c="; + }; + pnpmDeps = pnpm.fetchDeps { + inherit (finalAttrs) pname version src; + hash = "sha256-otogkSsKJ5j1BY00y4SRhL9pm7CK9nmzVisvGCDIMlU="; + }; + nativeBuildInputs = [ + node + pnpm + pnpm.configHook + jq + makeWrapper + ]; + pnpmInstallFlags = ["--frozen-lockfile"]; + + buildPhase = '' + runHook preBuild + pnpm install --offline --frozen-lockfile + pnpm --filter ./codex-cli... run build + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + pkgRoot=$out/lib/node_modules/${final.pname} + mkdir -p $pkgRoot + cp -R codex-cli/* $pkgRoot/ + + path=$(jq -r '.bin.codex' codex-cli/package.json) + mkdir -p $out/bin + makeWrapper ${node}/bin/node $out/bin/codex --add-flags "$pkgRoot/$path" + + runHook postInstall + ''; + + meta = with lib; { + description = "OpenAI Codex command‑line interface"; + license = licenses.asl20; + homepage = "https://github.com/openai/codex"; + }; +}) diff --git a/derivations/codex/rust.nix b/derivations/codex/rust.nix new file mode 100644 index 0000000..e07fb79 --- /dev/null +++ b/derivations/codex/rust.nix @@ -0,0 +1,63 @@ +{ + lib, + rustPlatform, + fetchFromGitHub, + nix-update-script, + pkg-config, + openssl, + versionCheckHook, +}: +rustPlatform.buildRustPackage (finalAttrs: { + pname = "codex"; + version = "0.4.0"; + + src = fetchFromGitHub { + owner = "openai"; + repo = "codex"; + rev = "f14b5adabf5db34864c44c1ffc6c566b018fe0cc"; + # tag = "rust-v${finalAttrs.version}"; + hash = "sha256-rRe0JFEO5ixxrZYDL8kxXDOH0n7lqabkXNNaSlNnQDg="; + }; + + sourceRoot = "${finalAttrs.src.name}/codex-rs"; + + useFetchCargoVendor = true; + cargoHash = "sha256-QIZ3V4NUo1VxJN3cwdQf3S0zwePnwdKKfch0jlIJacU="; + + nativeBuildInputs = [ + pkg-config + ]; + buildInputs = [ + openssl + ]; + + checkFlags = [ + "--skip=keeps_previous_response_id_between_tasks" # Requires network access + "--skip=retries_on_early_close" # Requires network access + ]; + + doInstallCheck = true; + nativeInstallCheckInputs = [versionCheckHook]; + + passthru = { + updateScript = nix-update-script { + extraArgs = [ + "--version-regex" + "^rust-v(\\d+\\.\\d+\\.\\d+)$" + ]; + }; + }; + + meta = { + description = "Lightweight coding agent that runs in your terminal"; + homepage = "https://github.com/openai/codex"; + changelog = "https://raw.githubusercontent.com/openai/codex/refs/tags/rust-v${finalAttrs.version}/CHANGELOG.md"; + license = lib.licenses.asl20; + mainProgram = "codex"; + maintainers = with lib.maintainers; [ + malo + delafthi + ]; + platforms = lib.platforms.unix; + }; +}) -- cgit v1.2.3