1
0
Fork 0
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:
Manuel 2025-03-24 20:04:19 +05:45 committed by GitHub
parent ad0614a1ec
commit 908e055e15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;