本文へスキップ
TakoAPI
スキル一覧に戻る
—まだ評価がありません
あなたの評価

概要

Nix flake for OpenAI Codex CLI - native Rust binary, hourly updates, multi-platform caching

説明

# codex-cli-nix

Always up-to-date Nix package for [OpenAI Codex](https://github.com/openai/codex) - lightweight AI coding agent in your terminal.

**🚀 Automatically updated hourly** to ensure you always have the latest Codex version.

**🦀 Now using native Rust binaries** - no Node.js dependency required!

## Why this package?

### Primary Goal: Always Up-to-Date Codex for Nix Users

This flake provides immediate access to the latest OpenAI Codex versions with:

1. **Native Rust Binary**: Self-contained binary, no runtime dependencies
2. **Hourly Automated Updates**: New Codex versions available within 1 hour of release
3. **Dedicated Maintenance**: Focused repository for quick fixes when Codex changes
4. **Flake-First Design**: Direct flake usage with Cachix binary cache
5. **Pre-built Binaries**: Multi-platform builds (Linux & macOS) cached for instant installation
6. **Node.js Runtime Option**: Alternative `codex-node` package for those who prefer Node.js

### Why Not Just Use npm Global?

While `npm install -g @openai/codex` works, it has critical limitations:
- **Disappears on Node.js Switch**: When projects use different Node.js versions (via asdf/nvm), Codex becomes unavailable
- **Must Reinstall Per Version**: Need to install Codex separately for each Node.js version
- **Not Declarative**: Can't be managed in your Nix configuration
- **Not Reproducible**: Different Node.js versions can cause inconsistencies
- **Outside Nix**: Doesn't integrate with Nix's dependency management

**Example Problem**: You're working on a legacy project that uses Node.js 16 via asdf. When you switch to that project, your globally installed Codex (from Node.js 22) disappears from your PATH. This flake solves this by bundling Node.js with Codex.

### Comparison Table

| Feature | npm global | This Flake |
|---------|------------|------------|
| **Latest Version** | ✅ Always | ✅ Hourly checks |
| **Native Binary** | ❌ Requires Node.js | ✅ Self-contained |
| **Survives Node Switch** | ❌ Lost on switch | ✅ Always available |
| **Binary Cache** | ❌ None | ✅ Cachix |
| **Declarative Config** | ❌ None | ✅ Yes |
| **Version Pinning** | ⚠️ Manual | ✅ Flake lock |
| **Update Frequency** | ✅ Immediate | ✅ <= 1 hour |
| **Reproducible** | ❌ No | ✅ Yes |
| **CI/CD Ready** | ❌ No | ✅ Yes |

## Quick Start

### Fastest Installation (Try it now!)

```bash
# Run native Codex directly without installing (recommended)
nix run github:sadjow/codex-cli-nix

# Or run the Node.js version
nix run github:sadjow/codex-cli-nix#codex-node
```

### Install to Your System

```bash
# Install native binary (recommended)
nix profile add github:sadjow/codex-cli-nix

# Or install the Node.js version
nix profile add github:sadjow/codex-cli-nix#codex-node
```

On Nix versions before 2.30 that do not provide `nix profile add`, use
`nix profile install` instead.

### Optional: Enable Binary Cache for Faster Installation

To download pre-built binaries instead of compiling:

```bash
# Install cachix if you haven't already
nix-env -iA cachix -f https://cachix.org/api/v1/install

# Add the codex-cli cache
cachix use codex-cli
```

Or add to your Nix configuration:

```nix
{
  nix.settings = {
    substituters = [ "https://codex-cli.cachix.org" ];
    trusted-public-keys = [ "codex-cli.cachix.org-1:YOUR_PUBLIC_KEY_HERE" ];
  };
}
```

## Using with Nix Flakes

### In your flake.nix

```nix
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    codex-cli-nix.url = "github:sadjow/codex-cli-nix";
  };

  outputs = { self, nixpkgs, codex-cli-nix }:
    let
      system = "x86_64-linux"; # or your system
      pkgs = nixpkgs.legacyPackages.${system};
    in
    {
      devShells.${system}.default = pkgs.mkShell {
        buildInputs = [
          codex-cli-nix.packages.${system}.default
        ];
      };
    };
}
```

### Using with NixOS

Add to your system configuration:

```nix
{ inputs, pkgs, ... }:
{
  environment.systemPackages = [
    inputs.codex-cli-nix.packages.${pkgs.system}.default
  ];
}
```

### Using with Home Manager

Add to your Home Manager configuration:

```nix
{ inputs, pkgs, ... }:
{
  home.packages = [
    inputs.codex-cli-nix.packages.${pkgs.system}.default
  ];
}
```

## Technical Details

### Package Architecture

Two package variants are available:

**`codex` (default, native binary)**
- Pre-built Rust CLI and required companion executable from OpenAI's GitHub releases
- Self-contained, no runtime dependencies
- Fastest startup time
- Supported platforms: `x86_64-linux`, `aarch64-linux`, `x86_64-darwin`, `aarch64-darwin`

**`codex-node` (alternative, Node.js runtime)**
- Traditional npm package with bundled Node.js 22 LTS
- Useful for debugging or if native binary has issues
- Works on all platforms supported by Node.js

### Features

- **Native Rust Binary**: Self-contained binary with no runtime dependencies (default)
- **Node.js Alternative**: Optional Node.js runtime for compatibility
- **Shell Completions**: Bash, Fish, and Zsh completions included with the default native package
- **Version Pinning**: Ensures consistent behavior across different environments
- **Auto-update Protection**: Prevents unexpected updates that might break your workflow
- **Cross-platform Support**: Pre-built binaries for Linux and macOS (x86_64 and ARM64)

## Development

```bash
# Clone the repository
git clone https://github.com/sadjow/codex-cli-nix
cd codex-cli-nix

# Build locally
nix build

# Test the build
./result/bin/codex --version

# Enter development shell
nix develop

# Run package and release-workflow regression checks
nix develop -c python3 -m unittest discover -s tests
```

## Updating Codex Version

### Automated Updates

This repository uses GitHub Actions to automatically check for new Codex versions hourly. When a new version is detected:

1. The update script refreshes the release artifact hashes and verifies the build on Linux
2. A pull request with the version update is created and squash-merged right away, because `main` has no required checks
3. The merged commit is built and smoke-tested on Linux and macOS and pushed to Cachix
4. Version tags are created and moved only after that build succeeds (`vX.Y.Z`, `vX`, `latest`)

The update branch is deleted on merge, so its pull request checks can show as failed with no jobs. The release gate is the build on `main`, and following `main` directly can pick up a version bump before that build has finished.

The automated update workflow runs:
- Every hour (on the hour) UTC
- On manual trigger via GitHub Actions UI

### Manual Updates

For manual updates:

1. Check for new versions:
   ```bash
   ./scripts/update.sh --check
   ```
2. Update to the latest version:
   ```bash
   ./scripts/update.sh
   ```

   Or update to a specific version:
   ```bash
   ./scripts/update.sh --version 0.144.3  # Replace with the desired version
   ```
3. Test the build:
   ```bash
   nix build
   ./result/bin/codex --version
   ```

### Push to Cachix manually
```bash
# Push native binary
nix build .#codex && cachix push codex-cli ./result

# Push Node.js version
nix build .#codex-node && cachix push codex-cli ./result
```

## Troubleshooting

### Command not found
Make sure the Nix profile bin directory is in your PATH:
```bash
export PATH="$HOME/.nix-profile/bin:$PATH"
```

### Permission issues on macOS

On macOS, Codex may ask for permissions after each Nix update because the binary path changes. To fix this:

1. Create a stable symlink: 
   ```bash
   mkdir -p ~/.local/bin
   ln -sf $(which codex) ~/.local/bin/codex
   ```
2. Add `~/.local/bin` to your PATH
3. Always run `codex` from `~/.local/bin/codex`

The wrapper script sets a consistent executable path to help prevent macOS permission resets.

### SSL certificate errors
The package automatically configures SSL certificates from the Nix store.

## Repository Settings

This repository requires specific GitHub settings for automated updates. See [Repository Settings Documentation](.github/REPOSITORY_SETTINGS.md) for configuration details.

## License

This Nix packaging is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

OpenAI Codex CLI itself is licensed under the Apache-2.0 License - see [OpenAI's repository](https://github.com/openai/codex) for details.

## Contributing

Contributions are welcome! Please submit pull requests or issues on GitHub.

## Related Projects

- [claude-code-nix](https://github.com/sadjow/claude-code-nix) - Similar packaging for Anthropic's Claude Code
- [Awesome Codex CLI](https://github.com/RoggeOhta/awesome-codex-cli) - Third-party Codex ecosystem directory listing this project
- [nixpkgs](https://github.com/NixOS/nixpkgs) - The Nix Packages collection

インストール

https://github.com/sadjow/codex-cli-nix からスキルをインストールして

このスキルはClawHubレジストリには公開されていません。Claude Code、Cursor、Codexなどのコーディングエージェントにプロンプトを貼り付けると、ソースリポジトリから直接インストールされます。

リポジトリを開く

リンク