From fe4585b462de6485999967ef15198f935713a158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Thu, 13 Nov 2025 11:04:01 -0500 Subject: [PATCH 1/3] feat: add configurable git diff/merge tools and GIT_CONFIG_GLOBAL support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add diffTool and mergeTool options to git module to allow configuration of git's diff and merge tools. Set up GIT_CONFIG_GLOBAL with [include] to maintain backwards compatibility with ~/.gitconfig. Update difftastic module to use the new git.diffTool option instead of GIT_EXTERNAL_DIFF. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/modules/integrations/difftastic.nix | 2 +- src/modules/integrations/git.nix | 26 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/modules/integrations/difftastic.nix b/src/modules/integrations/difftastic.nix index b8389fa70f..4a9f99cc37 100644 --- a/src/modules/integrations/difftastic.nix +++ b/src/modules/integrations/difftastic.nix @@ -10,6 +10,6 @@ config = lib.mkIf config.difftastic.enable { packages = [ pkgs.difftastic ]; - env.GIT_EXTERNAL_DIFF = "difft"; + git.diffTool = "difftastic"; }; } diff --git a/src/modules/integrations/git.nix b/src/modules/integrations/git.nix index ddc75ba116..5e3855d9b3 100644 --- a/src/modules/integrations/git.nix +++ b/src/modules/integrations/git.nix @@ -7,5 +7,31 @@ description = "Git repository root path. This field is populated automatically in devenv 1.10 and newer."; default = null; }; + + diffTool = lib.mkOption { + type = lib.types.nullOr lib.types.str; + description = "Git diff tool to use (e.g., 'difftastic', 'vimdiff')."; + default = null; + }; + + mergeTool = lib.mkOption { + type = lib.types.nullOr lib.types.str; + description = "Git merge tool to use (e.g., 'vimdiff', 'meld')."; + default = null; + }; + }; + + config = lib.mkIf (config.git.diffTool != null || config.git.mergeTool != null) { + env.GIT_CONFIG_GLOBAL = lib.concatStringsSep "\n" ( + [ "[include]" " path = ~/.gitconfig" ] ++ + lib.optionals (config.git.diffTool != null) [ + "[diff]" + " tool = ${config.git.diffTool}" + ] ++ + lib.optionals (config.git.mergeTool != null) [ + "[merge]" + " tool = ${config.git.mergeTool}" + ] + ); }; } From 3f1d9292297bffe23973d16f67f2b0f7dd4ffa05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Thu, 13 Nov 2025 11:16:07 -0500 Subject: [PATCH 2/3] feat: add mergiraf merge driver support with configurable drivers and conflict styles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add mergeDriver option to git module for registering custom git merge drivers like mergiraf. Add conflictStyle option to support diff3 and other conflict styles required by advanced merge tools. Create mergiraf module that enables mergiraf as a merge driver with automatic diff3 conflict style setup. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/modules/integrations/git.nix | 38 +++++++++++++++++++++++++-- src/modules/integrations/mergiraf.nix | 23 ++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 src/modules/integrations/mergiraf.nix diff --git a/src/modules/integrations/git.nix b/src/modules/integrations/git.nix index 5e3855d9b3..755d23af2d 100644 --- a/src/modules/integrations/git.nix +++ b/src/modules/integrations/git.nix @@ -19,19 +19,53 @@ description = "Git merge tool to use (e.g., 'vimdiff', 'meld')."; default = null; }; + + mergeDriver = lib.mkOption { + type = lib.types.attrsOf (lib.types.submodule { + options = { + name = lib.mkOption { + type = lib.types.str; + description = "Name of the merge driver."; + }; + driver = lib.mkOption { + type = lib.types.str; + description = "Driver command to run."; + }; + }; + }); + description = "Custom git merge drivers (e.g., mergiraf)."; + default = { }; + }; + + conflictStyle = lib.mkOption { + type = lib.types.nullOr lib.types.str; + description = "Git conflict style (e.g., 'merge', 'diff3', 'zdiff3')."; + default = null; + }; }; - config = lib.mkIf (config.git.diffTool != null || config.git.mergeTool != null) { + config = lib.mkIf (config.git.diffTool != null || config.git.mergeTool != null || config.git.mergeDriver != { } || config.git.conflictStyle != null) { env.GIT_CONFIG_GLOBAL = lib.concatStringsSep "\n" ( [ "[include]" " path = ~/.gitconfig" ] ++ lib.optionals (config.git.diffTool != null) [ "[diff]" " tool = ${config.git.diffTool}" ] ++ + lib.optionals (config.git.conflictStyle != null) [ + "[diff]" + " conflictStyle = ${config.git.conflictStyle}" + ] ++ lib.optionals (config.git.mergeTool != null) [ "[merge]" " tool = ${config.git.mergeTool}" - ] + ] ++ + lib.concatMap + (driverName: [ + "[merge \"${driverName}\"]" + " name = ${config.git.mergeDriver.${driverName}.name}" + " driver = ${config.git.mergeDriver.${driverName}.driver}" + ]) + (lib.attrNames config.git.mergeDriver) ); }; } diff --git a/src/modules/integrations/mergiraf.nix b/src/modules/integrations/mergiraf.nix new file mode 100644 index 0000000000..72be4e4b30 --- /dev/null +++ b/src/modules/integrations/mergiraf.nix @@ -0,0 +1,23 @@ +{ pkgs, lib, config, ... }: + +{ + options.mergiraf.enable = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Integrate mergiraf as git merge driver: https://mergiraf.org/"; + }; + + config = lib.mkIf config.mergiraf.enable { + packages = [ pkgs.mergiraf ]; + + git = { + mergeTool = "mergiraf"; + mergeDriver.mergiraf = { + name = "mergiraf"; + driver = "mergiraf merge --git %O %A %B -s %S -x %X -y %Y -p %P -l %L"; + }; + # mergiraf requires diff3 conflict style to reconstruct the base revision + conflictStyle = "diff3"; + }; + }; +} From 0bb66fbc27caf72803f4175eb2965b65a38caff7 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 13 Nov 2025 16:36:24 +0000 Subject: [PATCH 3/3] Auto generate docs/src/reference/options.md --- docs/src/reference/options.md | 137 ++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/docs/src/reference/options.md b/docs/src/reference/options.md index 3cb3f615db..69ed5dbfd0 100644 --- a/docs/src/reference/options.md +++ b/docs/src/reference/options.md @@ -3040,6 +3040,122 @@ null or YAML 1.1 value +## git.conflictStyle + + + +Git conflict style (e.g., ‘merge’, ‘diff3’, ‘zdiff3’). + + + +*Type:* +null or string + + + +*Default:* +` null ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/git.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/git.nix) + + + +## git.diffTool + + + +Git diff tool to use (e.g., ‘difftastic’, ‘vimdiff’). + + + +*Type:* +null or string + + + +*Default:* +` null ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/git.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/git.nix) + + + +## git.mergeDriver + + + +Custom git merge drivers (e.g., mergiraf). + + + +*Type:* +attribute set of (submodule) + + + +*Default:* +` { } ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/git.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/git.nix) + + + +## git.mergeDriver.\.driver + + + +Driver command to run. + + + +*Type:* +string + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/git.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/git.nix) + + + +## git.mergeDriver.\.name + + + +Name of the merge driver. + + + +*Type:* +string + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/git.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/git.nix) + + + +## git.mergeTool + + + +Git merge tool to use (e.g., ‘vimdiff’, ‘meld’). + + + +*Type:* +null or string + + + +*Default:* +` null ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/git.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/git.nix) + + + ## git.root @@ -18468,6 +18584,27 @@ package +## mergiraf.enable + + + +Integrate mergiraf as git merge driver: https://mergiraf.org/ + + + +*Type:* +boolean + + + +*Default:* +` false ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/mergiraf.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/mergiraf.nix) + + + ## name