at master 81 lines 2.3 kB view raw
1{ 2 lib, 3 stdenv, 4 rustPlatform, 5 fetchFromGitHub, 6 installShellFiles, 7 makeBinaryWrapper, 8 nix-update-script, 9 pkg-config, 10 openssl, 11 ripgrep, 12 versionCheckHook, 13 installShellCompletions ? stdenv.buildPlatform.canExecute stdenv.hostPlatform, 14}: 15rustPlatform.buildRustPackage (finalAttrs: { 16 pname = "codex"; 17 version = "0.42.0"; 18 19 src = fetchFromGitHub { 20 owner = "openai"; 21 repo = "codex"; 22 tag = "rust-v${finalAttrs.version}"; 23 hash = "sha256-YyI4quZ1vcwzDx38EzqycnUQDBOg9SfEemR4zdKYYIw="; 24 }; 25 26 sourceRoot = "${finalAttrs.src.name}/codex-rs"; 27 28 cargoHash = "sha256-No6/WmaCI+w1cVD+PsLJ1jK0zZDYziGlm9DD9E3hA58="; 29 30 nativeBuildInputs = [ 31 installShellFiles 32 makeBinaryWrapper 33 pkg-config 34 ]; 35 36 buildInputs = [ openssl ]; 37 38 # NOTE: part of the test suite requires access to networking, local shells, 39 # apple system configuration, etc. since this is a very fast moving target 40 # (for now), with releases happening every other day, constantly figuring out 41 # which tests need to be skipped, or finding workarounds, was too burdensome, 42 # and in practice not adding any real value. this decision may be reversed in 43 # the future once this software stabilizes. 44 doCheck = false; 45 46 postInstall = lib.optionalString installShellCompletions '' 47 installShellCompletion --cmd codex \ 48 --bash <($out/bin/codex completion bash) \ 49 --fish <($out/bin/codex completion fish) \ 50 --zsh <($out/bin/codex completion zsh) 51 ''; 52 53 postFixup = '' 54 wrapProgram $out/bin/codex --prefix PATH : ${lib.makeBinPath [ ripgrep ]} 55 ''; 56 57 doInstallCheck = true; 58 nativeInstallCheckInputs = [ versionCheckHook ]; 59 60 passthru = { 61 updateScript = nix-update-script { 62 extraArgs = [ 63 "--version-regex" 64 "^rust-v(\\d+\\.\\d+\\.\\d+)$" 65 ]; 66 }; 67 }; 68 69 meta = { 70 description = "Lightweight coding agent that runs in your terminal"; 71 homepage = "https://github.com/openai/codex"; 72 changelog = "https://raw.githubusercontent.com/openai/codex/refs/tags/rust-v${finalAttrs.version}/CHANGELOG.md"; 73 license = lib.licenses.asl20; 74 mainProgram = "codex"; 75 maintainers = with lib.maintainers; [ 76 malo 77 delafthi 78 ]; 79 platforms = lib.platforms.unix; 80 }; 81})