This commit is contained in:
Manuel 2024-05-01 18:38:43 +05:45 committed by GitHub
commit 71409d995c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 26 additions and 12 deletions

View File

@ -221,6 +221,12 @@ in {
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 {
type = types.enum [ "light" "dark" ];
@ -477,18 +483,26 @@ in {
};
})
(mkIf cfg.difftastic.enable {
home.packages = [ pkgs.difftastic ];
programs.git.iniContent = let
difftCommand = concatStringsSep " " [
"${pkgs.difftastic}/bin/difft"
"--color ${cfg.difftastic.color}"
"--background ${cfg.difftastic.background}"
"--display ${cfg.difftastic.display}"
];
in { diff.external = difftCommand; };
})
(let
difftCommand = concatStringsSep " " [
"${pkgs.difftastic}/bin/difft"
"--color ${cfg.difftastic.color}"
"--background ${cfg.difftastic.background}"
"--display ${cfg.difftastic.display}"
];
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
deltaPackage = cfg.delta.package;