Skip to content

chore: add nix flake#181

Open
matthew-hre wants to merge 3 commits intobug-ops:mainfrom
matthew-hre:chore/nix-flake
Open

chore: add nix flake#181
matthew-hre wants to merge 3 commits intobug-ops:mainfrom
matthew-hre:chore/nix-flake

Conversation

@matthew-hre
Copy link

Description

Add a Nix flake using flake-parts and crane for reproducible builds and development. This allows helix-trainer to be installed on NixOS, developed with Nix (the package manager), and run without installation via nix run.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test coverage improvement

Related Issues

None

Changes Made

  • Added a Nix flake to the root of the project
  • Added Nix installation section to README (run, NixOS/home-manager integration)
  • Added nix develop to CONTRIBUTING.md quick start

Testing

All existing tests pass, and all functionality remains the same. Entered the development environment with nix develop, built the program with nix build, and ran the program with nix run.

Test Results

  • All existing tests pass (cargo nextest run --lib)
  • Added new tests for new functionality (not required)
  • Manual testing completed
# Test commands run
cargo nextest run --lib
cargo clippy -- -D warnings
cargo +nightly fmt -- --check
cargo deny check

Test Coverage

No additional tests added

Screenshots/Demo

Checklist

  • Code follows the project's style guidelines
  • Self-review of code completed
  • Comments added for complex logic
  • Documentation updated (if applicable)
  • No new warnings generated
  • Tests added/updated and passing
  • CLAUDE.md updated (if architecture changed)
  • README.md updated (if user-facing changes)

Performance Impact

  • No performance impact
  • Performance improved
  • Performance impact assessed and acceptable

Security Considerations

  • No security impact
  • Security review completed
  • Input validation added/updated

Additional Notes

Additional maintenance realistically not needed - however, I am happy to help when needed!

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Mar 4, 2026
@matthew-hre matthew-hre changed the title Chore/nix flake chore: add nix flake Mar 4, 2026
@github-actions github-actions bot added the chore PRs with chore: prefix label Mar 4, 2026
@bug-ops bug-ops requested a review from Copilot March 4, 2026 14:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Nix flake support for reproducible builds/dev (via flake-parts + crane), enabling nix run, nix build, and nix develop workflows alongside existing Rust tooling.

Changes:

  • Introduces flake.nix/flake.lock to package and develop helix-trainer with Nix (including clippy/fmt checks and a dev shell).
  • Documents Nix installation and integration in README.md.
  • Updates contributor quick-start and ignores Nix build output symlink.

Reviewed changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
flake.nix Defines flake inputs/outputs, crane-based Rust build, checks, and dev shell.
flake.lock Pins nixpkgs/crane/flake-parts/rust-overlay/helix sources for reproducibility.
README.md Adds Nix usage docs (nix run + NixOS/home-manager integration snippet).
CONTRIBUTING.md Adds nix develop to quick start for contributor onboarding.
.gitignore Ignores the Nix result output symlink.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +112 to +113
# configuration.nix or home.nix
environment.systemPackages = [ inputs.helix-trainer.packages.${system}.default ];
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

The home-manager example uses environment.systemPackages, which is a NixOS option and won’t work in home.nix. Also ${system} isn’t defined in typical module configs; use ${pkgs.system} (or pkgs.system) and show the correct option for home-manager (e.g., home.packages).

Suggested change
# configuration.nix or home.nix
environment.systemPackages = [ inputs.helix-trainer.packages.${system}.default ];
# configuration.nix (NixOS)
environment.systemPackages = [ inputs.helix-trainer.packages.${pkgs.system}.default ];
# home.nix (home-manager)
home.packages = [ inputs.helix-trainer.packages.${pkgs.system}.default ];

Copilot uses AI. Check for mistakes.
clippy = craneLib.cargoClippy (commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

The Nix clippy check doesn’t enable all Cargo features (--all-features), so it can miss warnings that CI currently catches. Align this with the repository’s clippy invocation used in CI to avoid drift.

Suggested change
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
cargoClippyExtraArgs = "--all-features --all-targets -- --deny warnings";

Copilot uses AI. Check for mistakes.

# Patch the vendored deps to include languages.toml that
# helix-loader expects via include_bytes!("../../languages.toml")
vendorDir = craneLib.vendorCargoDeps {src = ./.;};
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

vendorCargoDeps is using src = ./.; (unfiltered), which will make Nix rebuild vendored deps when unrelated working-tree artifacts appear/change (notably the result symlink that this PR now ignores in git). Consider reusing the same filtered src you define below (or a cleanSource helper) so builds are stable and don’t depend on local artifacts.

Suggested change
vendorDir = craneLib.vendorCargoDeps {src = ./.;};
vendorDir = craneLib.vendorCargoDeps { src = src; };

Copilot uses AI. Check for mistakes.
Comment on lines +22 to +24
# Enter the dev shell (provides Rust 1.89, cargo-watch, cargo-deny, and native deps)
nix develop

Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

The quick start now suggests nix develop provides the dev tooling, but later steps require cargo +nightly fmt (rustup toolchain selector). The Nix dev shell currently pins a stable toolchain, so contributors following these instructions inside nix develop may be unable to run the formatting step. Either include a nightly toolchain/rustfmt in the dev shell or adjust the docs for Nix users.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore PRs with chore: prefix documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants