git: option to use difftastic as difftool
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
bfa7c06436
commit
d34d74f5ea
|
@ -221,6 +221,12 @@ in {
|
||||||
See <https://github.com/Wilfred/difftastic>.
|
See <https://github.com/Wilfred/difftastic>.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
enableAsDifftool = mkEnableOption "" // {
|
||||||
|
description = ''
|
||||||
|
Enable the {command}`difftastic` syntax highlighter as a git difftool.
|
||||||
|
See <https://github.com/Wilfred/difftastic>.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
background = mkOption {
|
background = mkOption {
|
||||||
type = types.enum [ "light" "dark" ];
|
type = types.enum [ "light" "dark" ];
|
||||||
|
@ -477,18 +483,26 @@ in {
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.difftastic.enable {
|
(let
|
||||||
home.packages = [ pkgs.difftastic ];
|
|
||||||
|
|
||||||
programs.git.iniContent = let
|
|
||||||
difftCommand = concatStringsSep " " [
|
difftCommand = concatStringsSep " " [
|
||||||
"${pkgs.difftastic}/bin/difft"
|
"${pkgs.difftastic}/bin/difft"
|
||||||
"--color ${cfg.difftastic.color}"
|
"--color ${cfg.difftastic.color}"
|
||||||
"--background ${cfg.difftastic.background}"
|
"--background ${cfg.difftastic.background}"
|
||||||
"--display ${cfg.difftastic.display}"
|
"--display ${cfg.difftastic.display}"
|
||||||
];
|
];
|
||||||
in { diff.external = difftCommand; };
|
in (lib.mkMerge [
|
||||||
|
(mkIf cfg.difftastic.enable {
|
||||||
|
home.packages = [ pkgs.difftastic ];
|
||||||
|
programs.git.iniContent = { diff.external = difftCommand; };
|
||||||
})
|
})
|
||||||
|
(mkIf cfg.difftastic.enableAsDifftool {
|
||||||
|
home.packages = [ pkgs.difftastic ];
|
||||||
|
programs.git.iniContent = {
|
||||||
|
diff = { tool = lib.mkDefault "difftastic"; };
|
||||||
|
difftool = { difftastic = { cmd = "difft $LOCAL $REMOTE"; }; };
|
||||||
|
};
|
||||||
|
})
|
||||||
|
]))
|
||||||
|
|
||||||
(let
|
(let
|
||||||
deltaPackage = cfg.delta.package;
|
deltaPackage = cfg.delta.package;
|
||||||
|
|
Loading…
Reference in a new issue