nix: add merge-driver for treefmt - #5224
Open
wolfgangwalther wants to merge 1 commit into
Open
Conversation
This adds a custom merge-driver and sets our nix-shell up to automatically activate it when entering the shell. This will allow us to transparently rebase through formatter-related changes without conflicts.
This was referenced Sep 6, 2026
Member
|
For reference about merge-driver: https://graphite.com/guides/git-merge-driver |
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.
This adds a custom merge-driver and sets our nix-shell up to automatically activate it when entering the shell. This will allow us to transparently rebase through formatter-related changes without conflicts.
I tested this with a branch changing the default nix formatter to
nixfmt(which is something that we should do as well - the one we're currently using is archived since 2024!).Let's assume this script is merged and we then merge a formatter change such as
nixfmtorfourmolutomain. Usage is then as simple as:nix-shellonmain. The merge-driver is activated via git config.treefmtstill makes sense.The important part is entering
nix-shellon the branch that already has the formatter changes innix/treefmt.nix. When entering the shell on the branch that needs rebasing, it would enable the old configuration, so would format everything the wrong way.