diff --git a/modules/programs/git.nix b/modules/programs/git.nix
index e76085192..28c208b76 100644
--- a/modules/programs/git.nix
+++ b/modules/programs/git.nix
@@ -405,6 +405,29 @@ in {
'';
};
};
+
+ riff = {
+ enable = mkEnableOption "" // {
+ description = ''
+ Enable the riff diff highlighter.
+ See .
+ '';
+ };
+
+ 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 RIFF environment variable.
+
+ Run riff --help 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;
+ })
]);
}