Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6bf5be2
add a github action to test the nix flake works and doesn't break
jessfraz Aug 20, 2025
57ca18c
fix
jessfraz Aug 20, 2025
d34e962
update the rust version in the flake this is bullshit
jessfraz Aug 20, 2025
c44ce17
other cleanups
jessfraz Aug 20, 2025
b3f958c
Merge branch 'main' into add-github-action-for-nix
jessfraz Aug 20, 2025
421247e
Merge branch 'main' into add-github-action-for-nix
jessfraz Aug 25, 2025
7c2b25f
Update .github/workflows/nix.yml
jessfraz Aug 26, 2025
966c387
Update .github/workflows/nix.yml
jessfraz Aug 26, 2025
da1b4d1
Update .github/workflows/nix.yml
jessfraz Aug 26, 2025
ce683b1
Update .github/workflows/nix.yml
jessfraz Aug 26, 2025
5772c1f
Update .github/workflows/nix.yml
jessfraz Aug 26, 2025
c1dbef4
Update .github/workflows/nix.yml
jessfraz Aug 26, 2025
26a77c3
Merge branch 'main' into add-github-action-for-nix
jessfraz Aug 26, 2025
8dde25f
Merge branch 'main' into add-github-action-for-nix
jessfraz Aug 27, 2025
3327434
Merge branch 'main' into add-github-action-for-nix
jessfraz Aug 28, 2025
3a5e774
Merge branch 'main' into add-github-action-for-nix
jessfraz Aug 29, 2025
cd40751
Merge branch 'main' into add-github-action-for-nix
jessfraz Sep 2, 2025
af44fce
Merge branch 'main' into add-github-action-for-nix
jessfraz Sep 3, 2025
e7059fa
Merge branch 'main' into add-github-action-for-nix
jessfraz Sep 3, 2025
49ba7c6
Merge branch 'main' into add-github-action-for-nix
jessfraz Sep 5, 2025
e532151
Merge branch 'main' into add-github-action-for-nix
jessfraz Sep 6, 2025
a25cadf
Merge branch 'main' into add-github-action-for-nix
jessfraz Sep 7, 2025
59613cc
Merge branch 'main' into add-github-action-for-nix
jessfraz Sep 12, 2025
bc97ddf
Merge branch 'main' into add-github-action-for-nix
jessfraz Sep 15, 2025
50fdbf9
Merge branch 'main' into add-github-action-for-nix
jessfraz Sep 16, 2025
d256560
Merge branch 'main' into add-github-action-for-nix
jessfraz Sep 16, 2025
2020b9d
Merge branch 'main' into add-github-action-for-nix
jessfraz Sep 16, 2025
1b7c84c
Merge branch 'main' into add-github-action-for-nix
jessfraz Sep 17, 2025
ecbd7fa
Merge branch 'main' into add-github-action-for-nix
jessfraz Sep 18, 2025
5ba0f7b
Merge branch 'main' into add-github-action-for-nix
jessfraz Sep 19, 2025
b50e3f5
Merge branch 'main' into add-github-action-for-nix
jessfraz Sep 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test Nix Flake
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
nix-flake-check:
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: nix flake check for all platforms
run: |
nix flake check --all-systems
nix-build-linux:
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: nix build . for x86_64-linux
run: nix build .
nix-build-macos:
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: nix build . for x86_64-darwin
run: nix build .
37 changes: 25 additions & 12 deletions codex-rs/default.nix
Original file line number Diff line number Diff line change
@@ -1,40 +1,53 @@
{ pkgs, monorep-deps ? [], ... }:
let
{
pkgs,
monorepo-deps ? [],
...
}: let
lib = pkgs.lib;

env = {
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig:$PKG_CONFIG_PATH";
};
in
rec {
in rec {
package = pkgs.rustPlatform.buildRustPackage {
inherit env;
pname = "codex-rs";
version = "0.1.0";
cargoLock.lockFile = ./Cargo.lock;
doCheck = false;
src = ./.;

cargoLock = {
lockFile = ./Cargo.lock;
# ratatui is patched via git, so we must whitelist its fixed-output hash
outputHashes = {
"ratatui-0.29.0" = "sha256-HBvT5c8GsiCxMffNjJGLmHnvG77A6cqEL+1ARurBXho=";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid this cannot be managed by dependabot or any automated system.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah its super unfortunate, and according to our mutual friend, o3, this seems like the lesser of evils...

I presume you all plan on getting your changes merged to ratatui upstream, that would definitely clean it up. But I'm also happy to help, this flake is a part of my dotfiles now, so you all can ping me whenever the action breaks, honestly I'd much prefer being pinged than the flake not work :)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Pls excuse the drive-by commenting)

If you do want to maintain this long term, you can write a small script that does something to the effect of nix-prefetch-url --unpack --type sha256 $URL and writes it into something like foo.nix then do import ./foo.nix there. Give or take some datastructure adjustments.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya that seems like a lot of extra work for something where there hasnt been changes in 3 weeks: https://github.com/nornagon/ratatui/tree/nornagon-v0.29.0-patch I'd like to better understand the plans to upstream

};
};

doCheck = false;

nativeBuildInputs = with pkgs; [
pkg-config
openssl
];
meta = with pkgs.lib; {
description = "OpenAI Codex command‑line interface rust implementation";

meta = with lib; {
description = "OpenAI Codex command line interface rust implementation";
license = licenses.asl20;
homepage = "https://github.com/openai/codex";
};
};

devShell = pkgs.mkShell {
inherit env;
name = "codex-rs-dev";
packages = monorep-deps ++ [
pkgs.cargo
package
];
packages = monorepo-deps ++ [package];
shellHook = ''
echo "Entering development shell for codex-rs"
alias codex="cd ${package.src}/tui; cargo run; cd -"
${pkgs.rustPlatform.cargoSetupHook}
'';
};

app = {
type = "app";
program = "${package}/bin/codex";
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

100 changes: 61 additions & 39 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,70 @@
};
};

outputs = { nixpkgs, flake-utils, rust-overlay, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
pkgsWithRust = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
monorepo-deps = with pkgs; [
# for precommit hook
pnpm
husky
outputs = {
self,
nixpkgs,
flake-utils,
rust-overlay,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
# Base pkgs with the Rust overlay
pkgsBase = import nixpkgs {
inherit system;
overlays = [rust-overlay.overlays.default];
};

# Use toolchain pinned in ./codex-rs/rust-toolchain.toml, fallback to stable 1.89.0
rustToolchain =
if builtins.pathExists ./codex-rs/rust-toolchain.toml
then pkgsBase.rust-bin.fromRustupToolchainFile ./codex-rs/rust-toolchain.toml
else pkgsBase.rust-bin.stable."1.89.0".default;

# Reimport pkgs and override rustPlatform to use that toolchain for builds
pkgs = import nixpkgs {
inherit system;
overlays = [
rust-overlay.overlays.default
(final: prev: {
rustPlatform = prev.makeRustPlatform {
cargo = rustToolchain;
rustc = rustToolchain;
};
})
];
codex-cli = import ./codex-cli {
inherit pkgs monorepo-deps;
};
codex-rs = import ./codex-rs {
pkgs = pkgsWithRust;
inherit monorepo-deps;
};
in
rec {
packages = {
codex-cli = codex-cli.package;
codex-rs = codex-rs.package;
};
};

devShells = {
codex-cli = codex-cli.devShell;
codex-rs = codex-rs.devShell;
};
monorepo-deps = with pkgs; [
pnpm
husky
];

codex-rs = import ./codex-rs {
inherit pkgs monorepo-deps;
};
in rec {
packages = {
codex-rs = codex-rs.package;
default = codex-rs.package;
};

apps = {
codex-rs = codex-rs.app;
default = codex-rs.app;
};

apps = {
codex-cli = codex-cli.app;
codex-rs = codex-rs.app;
devShells = {
# Dev shell includes the pinned toolchain on PATH
codex-rs = pkgs.mkShell {
packages = monorepo-deps ++ [rustToolchain codex-rs.package];
};
default = devShells.codex-rs;
};

defaultPackage = packages.codex-cli;
defaultApp = apps.codex-cli;
defaultDevShell = devShells.codex-cli;
}
);
# Optional CI hook to ensure the package builds
checks = {
codex-rs-build = packages.codex-rs;
};
});
}