feat(nix): Add comprehensive Nix pre-commit hooks#23
Merged
Conversation
This commit introduces six new pre-commit hooks for Nix development: 1. **nix-flake-check**: Validates flake.nix files using `nix flake check` 2. **nix-build-check**: Tests Nix builds for both flakes and legacy expressions 3. **nix-darwin-check**: Validates nix-darwin configurations (Darwin-only) 4. **nix-home-manager-check**: Tests home-manager configurations 5. **nix-fmt**: Formats Nix files (supports nixpkgs-fmt, alejandra, nixfmt) 6. **nix-lint**: Lints Nix files using statix and optionally deadnix All hooks include: - Automatic tool installation if missing - Support for both flakes and legacy Nix - Clear error messages - Configurable behavior via environment variables Also includes test fixtures for validating hook functionality. Closes #15, Closes #16, Closes #17, Closes #18, Closes #19, Closes #20, Closes #21 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a comprehensive set of pre-commit hooks for Nix development, providing validation, formatting, and linting capabilities for Nix files, flakes, darwin configurations, and home-manager setups.
New Hooks Added
Core Testing Hooks
nix-flake-check- Validates flake.nix files usingnix flake checknix-build-check- Tests Nix builds for both flakes and legacy expressionsnix-darwin-check- Validates nix-darwin configurations (Darwin-only)nix-home-manager-check- Tests home-manager configurationsCode Quality Hooks
nix-fmt- Formats Nix files (supports nixpkgs-fmt, alejandra, nixfmt)nix-lint- Lints Nix files using statix and optionally deadnixKey Features
Configuration Examples
Testing
All hooks have been tested with sample Nix configurations included in
tests/nix/fixtures/.Closes Issues
🤖 Generated with Claude Code