1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00

git: add option to use riff as diff tool

https://github.com/walles/riff
This commit is contained in:
seth 2024-08-17 06:39:26 -04:00
parent a42fa14b53
commit 9ee6e4aad7
No known key found for this signature in database
GPG key ID: D31BD0D494BBEE86

View file

@ -405,6 +405,29 @@ in {
'';
};
};
riff = {
enable = mkEnableOption "" // {
description = ''
Enable the <command>riff</command> diff highlighter.
See <link xlink:href="https://github.com/walles/riff" />.
'';
};
package = mkPackageOption pkgs "riffdiff" { };
commandLineOptions = mkOption {
type = types.listOf types.str;
default = [ ];
example = literalExpression ''[ "--no-adds-only-special" ]'';
apply = concatStringsSep " ";
description = ''
Command line arguments to include in the <command>RIFF</command> environment variable.
Run <command>riff --help</command> for a full list of options
'';
};
};
};
};
@ -418,6 +441,7 @@ in {
cfg.diff-so-fancy.enable
cfg.difftastic.enable
cfg.diff-highlight.enable
cfg.riff.enable
];
in count id enabled <= 1;
message =
@ -636,5 +660,25 @@ in {
};
};
})
(let riffExe = baseNameOf (getExe cfg.riff.package);
in mkIf cfg.riff.enable {
home.packages = [ cfg.riff.package ];
# https://github.com/walles/riff/blob/b17e6f17ce807c8652bc59cd46758661d23ce358/README.md#usage
programs.git.iniContent = {
pager = {
diff = riffExe;
log = riffExe;
show = riffExe;
};
interactive.diffFilter = "${riffExe} --color=on";
};
})
(mkIf (cfg.riff.enable && cfg.riff.commandLineOptions != "") {
home.sessionVariables.RIFF = cfg.riff.commandLineOptions;
})
]);
}