mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-31 04:04:32 +00:00
git: option to use difftastic as difftool (#5335)
I want `git diff` to stay the same, but `git difftool` to use difftastic, as described in the difftastic docs: https://difftastic.wilfred.me.uk/git.html#regular-usage
This commit is contained in:
parent
ad0614a1ec
commit
908e055e15
1 changed files with 29 additions and 12 deletions
|
@ -283,6 +283,13 @@ in {
|
|||
|
||||
package = mkPackageOption pkgs "difftastic" { };
|
||||
|
||||
enableAsDifftool = mkEnableOption "" // {
|
||||
description = ''
|
||||
Enable the {command}`difftastic` syntax highlighter as a git difftool.
|
||||
See <https://github.com/Wilfred/difftastic>.
|
||||
'';
|
||||
};
|
||||
|
||||
background = mkOption {
|
||||
type = types.enum [ "light" "dark" ];
|
||||
default = "light";
|
||||
|
@ -656,18 +663,28 @@ in {
|
|||
};
|
||||
})
|
||||
|
||||
(mkIf cfg.difftastic.enable {
|
||||
home.packages = [ cfg.difftastic.package ];
|
||||
|
||||
programs.git.iniContent = let
|
||||
difftCommand = concatStringsSep " " [
|
||||
"${getExe cfg.difftastic.package}"
|
||||
"--color ${cfg.difftastic.color}"
|
||||
"--background ${cfg.difftastic.background}"
|
||||
"--display ${cfg.difftastic.display}"
|
||||
];
|
||||
in { diff.external = difftCommand; };
|
||||
})
|
||||
(let
|
||||
difftCommand = concatStringsSep " " [
|
||||
"${getExe cfg.difftastic.package}"
|
||||
"--color ${cfg.difftastic.color}"
|
||||
"--background ${cfg.difftastic.background}"
|
||||
"--display ${cfg.difftastic.display}"
|
||||
];
|
||||
in (lib.mkMerge [
|
||||
(mkIf cfg.difftastic.enable {
|
||||
home.packages = [ cfg.difftastic.package ];
|
||||
programs.git.iniContent = { diff.external = difftCommand; };
|
||||
})
|
||||
(mkIf cfg.difftastic.enableAsDifftool {
|
||||
home.packages = [ cfg.difftastic.package ];
|
||||
programs.git.iniContent = {
|
||||
diff = { tool = lib.mkDefault "difftastic"; };
|
||||
difftool = {
|
||||
difftastic = { cmd = "${difftCommand} $LOCAL $REMOTE"; };
|
||||
};
|
||||
};
|
||||
})
|
||||
]))
|
||||
|
||||
(let
|
||||
deltaPackage = cfg.delta.package;
|
||||
|
|
Loading…
Add table
Reference in a new issue