Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions docs/src/reference/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.\<name>.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



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


Expand Down Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion src/modules/integrations/difftastic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
config = lib.mkIf config.difftastic.enable {
packages = [ pkgs.difftastic ];

env.GIT_EXTERNAL_DIFF = "difft";
git.diffTool = "difftastic";
};
}
60 changes: 60 additions & 0 deletions src/modules/integrations/git.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,65 @@
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;
};

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.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)
);
};
}
23 changes: 23 additions & 0 deletions src/modules/integrations/mergiraf.nix
Original file line number Diff line number Diff line change
@@ -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";
};
};
}