Skip to content

Add Nix flake + nix flake check CI - #1

Merged
schickling merged 2 commits into
mainfrom
add-nix-flake-and-ci
Jul 26, 2026
Merged

Add Nix flake + nix flake check CI#1
schickling merged 2 commits into
mainfrom
add-nix-flake-and-ci

Conversation

@schickling-assistant

@schickling-assistant schickling-assistant commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Adds a self-contained Nix flake + nix flake check CI, plus build-identity and shell completions. Rebased onto current main.

Kept intentionally lean — this is packaging, and it shouldn't fight your active development:

What's here (2 commits)

feat: build identity + shell completions

  • st2 --version follows the shared build-versioning contract: a stable machineVersion (0.1.0+<rev>[-dirty]) + a human displayVersion, from a CLI_BUILD_STAMP JSON stamp read via option_env!. The flake bakes an authoritative NixStamp from self (so a hermetic build knows its rev with no .git); build.rs bakes a LocalStamp from git for cargo build into a separate var, so it can never override the Nix stamp.
  • st2 completions <bash|zsh|fish|…> via clap_complete, generated from the live command tree (never drifts from the flags). No git deps added → cargoLock stays hash-free.

ci: add self-contained Nix flake + nix flake check

  • rustPlatform.buildRustPackage + cargoLock.lockFile. nix flake check builds the binary, runs the hermetic unit tests (--lib --bins, ~150), installs the completions, and smoke-tests --help + completions.

Two deliberate choices (so it doesn't fight you)

  • Unit tests only in the sandbox. The tests/*.rs integration tests each assume a real environment the Nix build sandbox lacks — /bin/bash + jq (the shipped Codex hooks), /usr/bin/git on a hardcoded PATH (materialize's git-worktree check), a live pty/convoy/systemd---user manager (the survival + render-neutrality gates). Chasing those with per-test skips is unbounded as the suite grows, so they run on native CI (a real runner) while the flake proves the package builds + its unit tests pass.
  • No cargo fmt/clippy gate, no repo-wide reformat. A format/lint gate on your hand-crafted tree would conflict with your own commits on every rebase. The devShell ships rustfmt + clippy for whoever wants them.

Totally understand if you want to reshape the flake (e.g. toward a function that produces an agent spec) — happy to iterate. This is just a working, rebased-clean baseline.

@schickling
schickling marked this pull request as ready for review July 25, 2026 13:59
@schickling

Copy link
Copy Markdown
Contributor

@codex

schickling-assistant and others added 2 commits July 26, 2026 10:28
`st2 --version` follows the shared build-versioning contract instead of a
bare `semver (sha)`: a stable machineVersion (`0.1.0+<rev>[-dirty]`) and a
human displayVersion, from a `CLI_BUILD_STAMP` JSON stamp (same env var +
shape as the fleet's TS/otel-scrape readers) via `option_env!`. The flake
bakes an authoritative NixStamp from `self` (no `.git` needed); `build.rs`
bakes a LocalStamp from git for `cargo build` in a separate var so it never
overrides the Nix stamp.

Shell completions: `st2 completions <bash|zsh|fish|…>` via clap_complete,
generated from the live command tree so they never drift from the flags.
No git deps added, so cargoLock stays hash-free.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Package st2 with rustPlatform.buildRustPackage (cargoLock.lockFile — no git
deps, so no per-dep hashes to maintain). `nix flake check` builds the binary,
runs the hermetic unit tests (`--lib --bins`), installs shell completions, and
smoke-tests `st2 --help` + the completions.

The integration tests in tests/*.rs assume a real environment the Nix sandbox
lacks (/bin/bash+jq, /usr/bin/git on a hardcoded PATH, live pty/convoy/systemd),
so they run on native CI rather than here. fmt/clippy are intentionally not
gated — a repo-wide format/lint gate would fight the maintainer's own commits;
the devShell ships rustfmt + clippy.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@schickling

Copy link
Copy Markdown
Contributor

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3bcc82d3d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread build.rs
@schickling
schickling requested a review from myobie July 26, 2026 09:30
@schickling
schickling merged commit d1f27b2 into main Jul 26, 2026
1 check passed
@myobie
myobie deleted the add-nix-flake-and-ci branch July 27, 2026 16:08
@schickling schickling added area:ci CI workflows, gates, and test infrastructure · Set: manual origin:agent Filed or primarily produced by an AI agent · Set: manual type:chore Maintenance, cleanup, dependencies, CI, or refactoring · Set: manual labels Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI workflows, gates, and test infrastructure · Set: manual origin:agent Filed or primarily produced by an AI agent · Set: manual type:chore Maintenance, cleanup, dependencies, CI, or refactoring · Set: manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants