Skip to content

Allow changing the diff tool used by flake check #475

@girlpunk

Description

@girlpunk

Is your feature request related to a problem? Please describe.

At the moment, treefmt-nix overwrites the default git config when running nix flake check. This is understandable given the possibility of sensitive options or those that require user-interaction, however it also resets the diff tool used.

Describe the solution you'd like

An option to set the diff tool to a custom program, such as difftastic (pkgs.difftastic), would be useful.

Describe alternatives you've considered

I was able to patch this in manually, though obviously this isn't an ideal solution.

diff --git a/module-options.nix b/module-options.nix
index ad83f35..a19d9c7 100644
--- a/module-options.nix
+++ b/module-options.nix
@@ -315,6 +315,7 @@ in
                 pkgs.git
                 pkgs.git-lfs
                 config.build.wrapper
+                pkgs.difftastic
               ];
               meta.description = "Check that the project tree is formatted";
             }
@@ -334,6 +335,13 @@ in
                 email = nix@localhost
               [init]
                 defaultBranch = main
+              [core]
+                conflictStyle = "diff3"
+              [diff]
+                external = "${pkgs.difftastic}/bin/difft "
+                tool = "difftastic"
+              [difftool "difftastic"]
+                cmd = "${pkgs.difftastic}/bin/difft  $LOCAL $REMOTE"
               EOF
               git init --quiet
               git add .

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions