Initial commit
This commit is contained in:
74
skills/nix-packaging/rust/codex/package.nix
Normal file
74
skills/nix-packaging/rust/codex/package.nix
Normal file
@@ -0,0 +1,74 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
rustPlatform,
|
||||
fetchFromGitHub,
|
||||
installShellFiles,
|
||||
nix-update-script,
|
||||
pkg-config,
|
||||
openssl,
|
||||
versionCheckHook,
|
||||
installShellCompletions ? stdenv.buildPlatform.canExecute stdenv.hostPlatform,
|
||||
}:
|
||||
rustPlatform.buildRustPackage (finalAttrs: {
|
||||
pname = "codex";
|
||||
version = "0.46.0";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "openai";
|
||||
repo = "codex";
|
||||
tag = "rust-v${finalAttrs.version}";
|
||||
hash = "sha256-o898VjjPKevr1VRlRhJUNWsrHEGEn7jkdzWBj+DpbCs=";
|
||||
};
|
||||
|
||||
sourceRoot = "${finalAttrs.src.name}/codex-rs";
|
||||
|
||||
cargoHash = "sha256-Qp5zezXjVdOp8OylLgUZRLc0HQlgII6nOZodnOrok6U=";
|
||||
|
||||
nativeBuildInputs = [
|
||||
installShellFiles
|
||||
pkg-config
|
||||
];
|
||||
|
||||
buildInputs = [ openssl ];
|
||||
|
||||
# NOTE: part of the test suite requires access to networking, local shells,
|
||||
# apple system configuration, etc. since this is a very fast moving target
|
||||
# (for now), with releases happening every other day, constantly figuring out
|
||||
# which tests need to be skipped, or finding workarounds, was too burdensome,
|
||||
# and in practice not adding any real value. this decision may be reversed in
|
||||
# the future once this software stabilizes.
|
||||
doCheck = false;
|
||||
|
||||
postInstall = lib.optionalString installShellCompletions ''
|
||||
installShellCompletion --cmd codex \
|
||||
--bash <($out/bin/codex completion bash) \
|
||||
--fish <($out/bin/codex completion fish) \
|
||||
--zsh <($out/bin/codex completion zsh)
|
||||
'';
|
||||
|
||||
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;
|
||||
};
|
||||
})
|
||||
14
skills/nix-packaging/rust/rust.md
Normal file
14
skills/nix-packaging/rust/rust.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# Packaging Rust Applications with Nix
|
||||
|
||||
See [codex](./codex/package.nix) for an example.
|
||||
|
||||
## Updating an Existing Rust Package
|
||||
|
||||
Besides the general update steps, also update the `cargoHash`:
|
||||
|
||||
```bash
|
||||
# Set cargoHash = ""; then run nix build
|
||||
# Nix will fail and show: "got: sha256-XXXXX"
|
||||
```
|
||||
|
||||
If `Cargo.toml` dependencies changed, the build will automatically fetch new dependencies after you update the `cargoHash`.
|
||||
Reference in New Issue
Block a user