Skip to content

Conversation

@lucperkins
Copy link
Member

@lucperkins lucperkins commented Nov 4, 2025

Not an urgent thing but it does remove one bulky dependency and, from my perspective, simplifies the dev shell logic at least a little bit.

Summary by CodeRabbit

  • Refactor

    • Restructured pre-commit hook system for per-system configuration and improved modularity
    • Updated development environment setup with new hook infrastructure
  • Chores

    • Removed external flake-parts framework dependency
    • Consolidated and reorganized pre-commit hook settings structure

Summary by CodeRabbit

  • New Features

    • Per-system pre-commit hook configuration with a centralized hook settings provider.
    • Built-in hooks: merge-conflict detection, Meson formatter integration, nix-format style rules, clang-format exclusions, and shellcheck.
  • Refactor

    • Development shells and system checks now use the new per-system hook wiring for pre-commit integration.
  • Chores

    • Removed legacy development wiring and an older flake-based module previously exposing pre-commit settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 4, 2025

Walkthrough

Replaces devFlake/flake-parts wiring with a new per-system preCommitHooksFor exported from flake.nix; adds packaging/pre-commit-hook-settings.nix; updates packaging/dev-shell.nix to use preCommitHooksFor; removes maintainers/flake-module.nix and related flake-parts inputs and exports.

Changes

Cohort / File(s) Summary
Flake outputs & wiring
flake.nix
Added public preCommitHooksFor = system: { check, settings }; import packaging/pre-commit-hook-settings.nix; wired checks to include pre-commit-check = (preCommitHooksFor system).check; replaced devFlake usage with preCommitHooksFor in devShells; removed inputs.flake-parts entries and devFlake-related exports.
Pre-commit hook settings
packaging/pre-commit-hook-settings.nix
New file exporting { pkgs, lib, src }: that returns { hooks = { ... } } with entries: check-merge-conflicts, check-merge-conflicts-2 (script), meson-format (patch + script), nixfmt-rfc-style (exclusions), clang-format (exclusions), and shellcheck.
Dev shell integration
packaging/dev-shell.nix
Replaced devFlake parameter with preCommitHooksFor; bind modular to preCommitHooksFor per-system; set _NIX_PRE_COMMIT_HOOKS_CONFIG to modular.shellHook; replaced modular.pre-commit.settings.package/installationScript with pkgs.buildPackages.pre-commit; updated exported attribute list.
Legacy flake module removal
maintainers/flake-module.nix
Deleted the entire flake module: removed export of flake.getSystem, perSystem pre-commit settings, imports of inputs.git-hooks-nix.flakeModule, and all hook/script definitions previously provided there.

Sequence Diagram

sequenceDiagram
    participant Flake as flake.nix
    participant HooksFile as packaging/pre-commit-hook-settings.nix
    participant DevShell as packaging/dev-shell.nix
    participant Checks as flake checks

    rect rgb(245,250,245)
    Note over Flake,HooksFile: New per-system hook wiring
    Flake->>HooksFile: import (pkgs, lib, src)
    Flake->>Flake: expose preCommitHooksFor(system) -> { check, settings }
    Flake->>DevShell: pass preCommitHooksFor into dev-shell
    DevShell->>DevShell: set _NIX_PRE_COMMIT_HOOKS_CONFIG = modular.shellHook
    Flake->>Checks: checks[system].pre-commit-check = (preCommitHooksFor system).check
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Review packaging/pre-commit-hook-settings.nix scripts, patch application, generated entry scripts, and path exclusions.
  • Verify flake.nix preCommitHooksFor evaluation per system and its interaction with checks and devShells.
  • Confirm packaging/dev-shell.nix env changes, nativeBuildInputs, and removal of devFlake wiring.
  • Search for leftover references to devFlake, flake-parts, or the removed maintainers/flake-module.nix.

Poem

🐇
I hopped through lines of code to see,
Hooks rearranged for each system and me.
Old module fades, new settings sow,
I nibble the patches, tidy and slow.
A carrot-shaped commit — ready to grow.

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly summarizes the main objective: removing the flake-parts dependency, which is the primary goal of the changeset across all modified files.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch remove-flake-parts

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ac5664e and b7f112e.

📒 Files selected for processing (2)
  • flake.nix (3 hunks)
  • packaging/pre-commit-hook-settings.nix (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: build_x86_64-linux / manual
  • GitHub Check: build_x86_64-linux / test
  • GitHub Check: build_x86_64-linux / vm_tests_smoke
  • GitHub Check: build_aarch64-darwin / build

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.

@github-actions
Copy link

github-actions bot commented Nov 4, 2025

@github-actions github-actions bot temporarily deployed to pull request November 4, 2025 17:43 Inactive
Copy link

@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 (1)
packaging/pre-commit-hook-settings.nix (1)

9-25: Consider consolidating the merge conflict checks.

Both check-merge-conflicts (line 9) and check-merge-conflicts-2 (lines 10-25) detect merge conflict markers. This duplication may be unnecessary.

If the built-in hook is sufficient, consider removing the custom script:

-    check-merge-conflicts.enable = true;
-    check-merge-conflicts-2 = {
-      enable = true;
-      entry = "${pkgs.writeScript "check-merge-conflicts" ''
-        #!${pkgs.runtimeShell}
-        conflicts=false
-        for file in "$@"; do
-          if grep --with-filename --line-number -E '^>>>>>>> ' -- "$file"; then
-            conflicts=true
-          fi
-        done
-        if $conflicts; then
-          echo "ERROR: found merge/patch conflicts in files"
-          exit 1
-        fi
-      ''}";
-    };
+    check-merge-conflicts.enable = true;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 530c34c and 746d5c8.

⛔ Files ignored due to path filters (1)
  • flake.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • flake.nix (3 hunks)
  • maintainers/flake-module.nix (0 hunks)
  • packaging/dev-shell.nix (4 hunks)
  • packaging/pre-commit-hook-settings.nix (1 hunks)
💤 Files with no reviewable changes (1)
  • maintainers/flake-module.nix
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: build_x86_64-linux / manual
  • GitHub Check: build_x86_64-linux / vm_tests_smoke
  • GitHub Check: build_aarch64-darwin / build
🔇 Additional comments (6)
packaging/pre-commit-hook-settings.nix (1)

49-77: LGTM!

The hook configurations for nixfmt-rfc-style, clang-format, and shellcheck are well-structured with appropriate exclusions for test files and vendored code.

packaging/dev-shell.nix (3)

3-3: LGTM!

The parameter change from devFlake to preCommitHooksFor and its usage at line 14 correctly integrate with the new pre-commit hook architecture.

Also applies to: 14-14


76-78: LGTM!

The updated reference to modular.settings correctly accesses the pre-commit configuration from the new preCommitHooksFor structure.


118-118: LGTM!

Adding pkgs.buildPackages.pre-commit directly to nativeBuildInputs is a cleaner approach than the previous indirection through the modular settings.

flake.nix (2)

76-90: LGTM!

The preCommitHooksFor function is well-structured and provides clean per-system pre-commit hook configuration. The return value exposes both the check derivation and the settings for use in dev shells.


350-352: LGTM!

The integration of preCommitHooksFor into both the checks output (lines 350-352) and dev shell construction (line 501) is correct and maintains consistency across the flake outputs.

Also applies to: 501-501

@github-actions github-actions bot temporarily deployed to pull request November 4, 2025 17:53 Inactive
Copy link

@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

♻️ Duplicate comments (1)
packaging/pre-commit-hook-settings.nix (1)

26-48: Verify meson.format location and consider patch reliability.

The path ${../meson.format} (line 45) should resolve to the repository root. Please verify this file exists at the expected location.

Additionally, fetching a patch from GitHub (lines 32-35) can be fragile if the URL becomes unavailable or if the upstream commit is rebased/deleted.

Run the following script to verify the meson.format file location:

#!/bin/bash
# Description: Verify meson.format exists at repository root

if [ -f "meson.format" ]; then
  echo "✓ meson.format exists at repository root"
  head -n 10 meson.format
else
  echo "✗ ERROR: meson.format not found at repository root"
  echo "Searching for meson.format elsewhere:"
  fd -t f "^meson.format$"
fi
🧹 Nitpick comments (1)
packaging/pre-commit-hook-settings.nix (1)

67-75: Consider pinning llvmPackages version.

Using pkgs.llvmPackages_latest (line 69) means clang-format behavior could change unexpectedly with Nixpkgs updates. Consider pinning to a specific version (e.g., llvmPackages_19) for reproducibility.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 746d5c8 and 7a5ed1c.

📒 Files selected for processing (3)
  • flake.nix (3 hunks)
  • packaging/dev-shell.nix (4 hunks)
  • packaging/pre-commit-hook-settings.nix (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packaging/dev-shell.nix
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: build_x86_64-linux / manual
  • GitHub Check: build_x86_64-linux / vm_tests_smoke
  • GitHub Check: build_x86_64-linux / test
  • GitHub Check: build_aarch64-darwin / build
🔇 Additional comments (6)
packaging/pre-commit-hook-settings.nix (3)

1-8: LGTM!

The function signature and structure are clean and follow Nix conventions for modular configuration.


49-66: LGTM!

The nixfmt-rfc-style configuration appropriately excludes test files that may require non-standard formatting for validation purposes.


76-76: LGTM!

Enabling shellcheck is excellent for catching common shell scripting issues.

flake.nix (3)

76-86: LGTM!

The preCommitHooksFor function correctly wires the pre-commit hook settings from the new modular configuration file. The src = self on line 86 is correctly provided to git-hooks-nix.lib.run as required by that API.


346-348: LGTM!

Exposing the pre-commit checks in the checks output is excellent for CI/CD integration, ensuring hooks run automatically in continuous integration.


497-497: LGTM!

The dev shell integration with preCommitHooksFor successfully replaces the flake-parts dependency, aligning with the PR objective.

@github-actions github-actions bot temporarily deployed to pull request November 4, 2025 17:56 Inactive
Copy link

@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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7a5ed1c and ac5664e.

📒 Files selected for processing (1)
  • flake.nix (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: build_aarch64-darwin / manual
  • GitHub Check: build_x86_64-linux / vm_tests_smoke
  • GitHub Check: build_x86_64-linux / manual
  • GitHub Check: build_x86_64-linux / test
🔇 Additional comments (2)
flake.nix (2)

81-86: No changes needed—the code pattern is correct.

The verification confirms the implementation follows the expected pattern. The src = self passed to the import at line 83 and merged again at line 86 is correct behavior: packaging/pre-commit-hook-settings.nix receives src as input but returns only the hooks configuration object without it, so src must be re-added to the final configuration before passing to inputs.git-hooks-nix.lib.${system}.run, which requires it.


497-497: ✓ Signature compatibility verified.

The dev-shell.nix function signature correctly expects lib and preCommitHooksFor as parameters. Both are actively used: preCommitHooksFor is called with the build platform system (line 14), and lib is used throughout for utility functions (lib.optionals, lib.optionalAttrs, lib.optional, etc.). The function call in flake.nix is correctly passing both parameters.

@github-actions github-actions bot temporarily deployed to pull request November 4, 2025 18:01 Inactive
@github-actions github-actions bot temporarily deployed to pull request November 4, 2025 18:33 Inactive
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