Skip to content

chore: nix flake + package + dev shell#55

Merged
jsbroks merged 1 commit intoctrlplanedev:mainfrom
zachspar:spar/feat/nix-pkg
Feb 19, 2026
Merged

chore: nix flake + package + dev shell#55
jsbroks merged 1 commit intoctrlplanedev:mainfrom
zachspar:spar/feat/nix-pkg

Conversation

@zachspar
Copy link
Copy Markdown
Contributor

@zachspar zachspar commented Feb 19, 2026

Background

Adding an alternate mechanism for installing ctrlc using nix.

What's Changed

  • nix flake with package
    • ability to install ctrlc using nix
  • nix dev shell
    • simply running nix develop will install dependencies locally and let you run build

Summary by CodeRabbit

  • Chores
    • Added Nix Flake configuration for the Ctrlplane CLI, enabling standardized and reproducible development environments
    • Updated repository ignore patterns to maintain cleaner version control state

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 19, 2026

📝 Walkthrough

Walkthrough

Two infrastructure configuration files were modified: .gitignore patterns were extended to ignore additional directories (.history, result, result-*), and a new Nix Flake configuration was introduced for building and packaging the ctrlc CLI with standardized development environment tooling.

Changes

Cohort / File(s) Summary
Gitignore Patterns
.gitignore
Added ignore patterns for .history, result, and result-* directories; adjusted newline termination for switch.sh.
Nix Flake Configuration
flake.nix
New Nix Flake defining build and development environment for ctrlc CLI. Configures pkgs.buildGoModule with version derivation, vendorHash, build flags (CGO_ENABLED=0), and ldflags for version injection. Includes devShell with Go 1.24, golangci-lint, and goreleaser.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Poem

🐰 A flake to build with Nix so fine,
Result and history left behind,
The CLI bundles up just right,
Dev tools glowing in the night—
ctrlc compiles without a fuss,
Our build pipeline now robust! 🚀

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a Nix flake, package, and development shell to the project.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (4)
flake.nix (3)

48-48: Simplify default by referencing ctrlc via a let binding instead of self.

self.packages.${system}.ctrlc is valid (Nix resolves self lazily as a fixpoint), but it introduces an indirect self-dependency that's harder to follow. Extracting the derivation to a let binding is the idiomatic approach and avoids the circular reference entirely.

✏️ Suggested refactor
       in
       {
+        let
+          ctrlcPkg = pkgs.buildGoModule {  # or buildGo124Module
+            pname = "ctrlc";
+            ...
+          };
+        in
         packages = {
-          ctrlc = pkgs.buildGoModule {
-            pname = "ctrlc";
-            ...
-          };
-
-          default = self.packages.${system}.ctrlc;
+          ctrlc = ctrlcPkg;
+          default = ctrlcPkg;
         };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@flake.nix` at line 48, Replace the indirect self-reference for the default
package by introducing a local let binding for the ctrlc derivation and then use
that binding for default; specifically, define a let binding (e.g., ctrlc =
self.packages.${system}.ctrlc) or better yet reference the ctrlc derivation
directly from packages within the top-level let, then set default = ctrlc so you
avoid the circular self.packages.${system}.ctrlc reference and make the intent
explicit.

21-21: Go version inconsistency between buildGoModule and devShell's go_1_24.

buildGoModule uses the nixpkgs-default Go toolchain, which may differ from go_1_24 pinned in devShells.default (line 53). buildGo124Module is a versioned builder that pins Go 1.24 specifically. Using it here would guarantee the package is compiled with the same toolchain version that developers get via nix develop.

✏️ Suggested change
-          ctrlc = pkgs.buildGoModule {
+          ctrlc = pkgs.buildGo124Module {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@flake.nix` at line 21, Replace the use of buildGoModule for the ctrlc package
with the Go 1.24-specific builder to ensure toolchain parity with the devShell;
locate the ctrlc declaration that currently uses buildGoModule and switch it to
buildGo124Module so the package is compiled with Go 1.24 (matching
devShells.default's go_1_24), keeping the existing attrs and inputs the same.

26-26: Add a comment documenting that vendorHash must be updated whenever go.mod/go.sum changes.

Since this project does not use a committed vendor/ directory, the standard workflow applies: when dependencies change, set vendorHash = lib.fakeHash; and run the build to obtain the correct hash value, then update it in flake.nix.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@flake.nix` at line 26, Add a short inline comment next to the vendorHash
declaration documenting that vendorHash must be updated whenever dependencies
change (i.e., when go.mod or go.sum change); instruct maintainers to temporarily
set vendorHash = lib.fakeHash, run the build to obtain the real hash, and then
replace the placeholder with the returned hash so the flake stays reproducible
(refer to the vendorHash symbol to locate where to add this note).
.gitignore (1)

9-10: Consider root-anchoring the Nix output patterns for consistency.

result and result-* without a leading slash match anywhere in the directory tree. Nix places these symlinks only in the project root (where nix build is run), and the existing /bin entry is already root-anchored. Using /result and /result-* makes the intent explicit and is consistent.

✏️ Suggested change
-.history
-result
-result-*
+.history
+/result
+/result-*
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.gitignore around lines 9 - 10, Update the .gitignore patterns for Nix build
outputs to be root-anchored: replace the unanchored entries "result" and
"result-*" with "/result" and "/result-*" so they only match symlinks at the
repository root (consistent with the existing "/bin" entry); modify the lines
referencing "result" and "result-*" accordingly in the .gitignore file.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@flake.nix`:
- Around line 1-7: flake.nix declares external inputs (nixpkgs and flake-utils)
but the repository is missing the generated flake.lock; run `nix flake lock` at
the repo root to produce flake.lock (pinning the nixpkgs and flake-utils
revisions) and add/commit the resulting flake.lock to the PR so the flake.nix
inputs are reproducibly recorded.

---

Nitpick comments:
In @.gitignore:
- Around line 9-10: Update the .gitignore patterns for Nix build outputs to be
root-anchored: replace the unanchored entries "result" and "result-*" with
"/result" and "/result-*" so they only match symlinks at the repository root
(consistent with the existing "/bin" entry); modify the lines referencing
"result" and "result-*" accordingly in the .gitignore file.

In `@flake.nix`:
- Line 48: Replace the indirect self-reference for the default package by
introducing a local let binding for the ctrlc derivation and then use that
binding for default; specifically, define a let binding (e.g., ctrlc =
self.packages.${system}.ctrlc) or better yet reference the ctrlc derivation
directly from packages within the top-level let, then set default = ctrlc so you
avoid the circular self.packages.${system}.ctrlc reference and make the intent
explicit.
- Line 21: Replace the use of buildGoModule for the ctrlc package with the Go
1.24-specific builder to ensure toolchain parity with the devShell; locate the
ctrlc declaration that currently uses buildGoModule and switch it to
buildGo124Module so the package is compiled with Go 1.24 (matching
devShells.default's go_1_24), keeping the existing attrs and inputs the same.
- Line 26: Add a short inline comment next to the vendorHash declaration
documenting that vendorHash must be updated whenever dependencies change (i.e.,
when go.mod or go.sum change); instruct maintainers to temporarily set
vendorHash = lib.fakeHash, run the build to obtain the real hash, and then
replace the placeholder with the returned hash so the flake stays reproducible
(refer to the vendorHash symbol to locate where to add this note).

Comment on lines +1 to +7
{
description = "Ctrlplane CLI (ctrlc)";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot Feb 19, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

flake.lock must be committed alongside flake.nix.

flake.lock ensures Nix flakes have purely deterministic outputs; a flake.nix without an accompanying flake.lock should be considered incomplete. Without it, every nix build or nix develop invocation resolves nixpkgs and flake-utils to whatever revision is current at that moment, defeating the reproducibility guarantee. Any Nix CLI command run against the flake — like nix build, nix develop, or even nix flake show — generates a flake.lock for you.

Please run nix flake lock and commit the resulting flake.lock in this PR.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@flake.nix` around lines 1 - 7, flake.nix declares external inputs (nixpkgs
and flake-utils) but the repository is missing the generated flake.lock; run
`nix flake lock` at the repo root to produce flake.lock (pinning the nixpkgs and
flake-utils revisions) and add/commit the resulting flake.lock to the PR so the
flake.nix inputs are reproducibly recorded.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's already there :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if flake.lock exists in the repository
if [ -f "flake.lock" ]; then
  echo "flake.lock EXISTS"
  # Show first few lines to confirm it's a valid lock file
  head -20 flake.lock
else
  echo "flake.lock NOT FOUND"
fi

# Also list files in the root to see what's there
echo "---"
echo "Files in repository root:"
ls -la | grep -E "(flake|nix)"

Length of output: 659


@zachspar You're absolutely right, and I apologize for the incorrect flag! 🙏

I've confirmed that flake.lock is indeed present in the repository (1,497 bytes) and contains the properly locked versions of your inputs:

  • flake-utils (locked to commit 11707dc...)
  • nixpkgs references

The flake is complete and ready for reproducible builds. Thank you for the correction!

@jsbroks jsbroks merged commit 20b4b09 into ctrlplanedev:main Feb 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants