nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 107 lines 2.9 kB view raw
1{ 2 lib, 3 stdenv, 4 rustPlatform, 5 fetchFromGitHub, 6 installShellFiles, 7 clang, 8 cmake, 9 gitMinimal, 10 libclang, 11 makeBinaryWrapper, 12 nix-update-script, 13 pkg-config, 14 openssl, 15 ripgrep, 16 versionCheckHook, 17 installShellCompletions ? stdenv.buildPlatform.canExecute stdenv.hostPlatform, 18}: 19rustPlatform.buildRustPackage (finalAttrs: { 20 pname = "codex"; 21 version = "0.92.0"; 22 23 src = fetchFromGitHub { 24 owner = "openai"; 25 repo = "codex"; 26 tag = "rust-v${finalAttrs.version}"; 27 hash = "sha256-m/g+5wdehyaHDw6i5vik4HXiisY/iWFtPX0gKjCFPNY="; 28 }; 29 30 sourceRoot = "${finalAttrs.src.name}/codex-rs"; 31 32 cargoHash = "sha256-fuT8vPb9/7fZam129nR6y+r+3j46WBhlf73Htkcjpzc="; 33 34 nativeBuildInputs = [ 35 clang 36 cmake 37 gitMinimal 38 installShellFiles 39 makeBinaryWrapper 40 pkg-config 41 ]; 42 43 buildInputs = [ 44 libclang 45 openssl 46 ]; 47 48 # NOTE: set LIBCLANG_PATH so bindgen can locate libclang, and adjust 49 # warning-as-error flags to avoid known false positives (GCC's 50 # stringop-overflow in BoringSSL's a_bitstr.cc) while keeping Clang's 51 # character-conversion warning-as-error disabled. 52 env = { 53 LIBCLANG_PATH = "${lib.getLib libclang}/lib"; 54 NIX_CFLAGS_COMPILE = toString ( 55 lib.optionals stdenv.cc.isGNU [ 56 "-Wno-error=stringop-overflow" 57 ] 58 ++ lib.optionals stdenv.cc.isClang [ 59 "-Wno-error=character-conversion" 60 ] 61 ); 62 }; 63 64 # NOTE: part of the test suite requires access to networking, local shells, 65 # apple system configuration, etc. since this is a very fast moving target 66 # (for now), with releases happening every other day, constantly figuring out 67 # which tests need to be skipped, or finding workarounds, was too burdensome, 68 # and in practice not adding any real value. this decision may be reversed in 69 # the future once this software stabilizes. 70 doCheck = false; 71 72 postInstall = lib.optionalString installShellCompletions '' 73 installShellCompletion --cmd codex \ 74 --bash <($out/bin/codex completion bash) \ 75 --fish <($out/bin/codex completion fish) \ 76 --zsh <($out/bin/codex completion zsh) 77 ''; 78 79 postFixup = '' 80 wrapProgram $out/bin/codex --prefix PATH : ${lib.makeBinPath [ ripgrep ]} 81 ''; 82 83 doInstallCheck = true; 84 nativeInstallCheckInputs = [ versionCheckHook ]; 85 86 passthru = { 87 updateScript = nix-update-script { 88 extraArgs = [ 89 "--version-regex" 90 "^rust-v(\\d+\\.\\d+\\.\\d+)$" 91 ]; 92 }; 93 }; 94 95 meta = { 96 description = "Lightweight coding agent that runs in your terminal"; 97 homepage = "https://github.com/openai/codex"; 98 changelog = "https://raw.githubusercontent.com/openai/codex/refs/tags/rust-v${finalAttrs.version}/CHANGELOG.md"; 99 license = lib.licenses.asl20; 100 mainProgram = "codex"; 101 maintainers = with lib.maintainers; [ 102 malo 103 delafthi 104 ]; 105 platforms = lib.platforms.unix; 106 }; 107})