1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-06 08:46:54 +00:00

git: add option to use riff as diff tool (#5748)

https://github.com/walles/riff
This commit is contained in:
Seth Flynn 2025-02-22 20:43:56 -05:00 committed by GitHub
parent 6b7cd50812
commit 3b6550f710
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -411,6 +411,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
'';
};
};
};
};
@ -434,6 +457,7 @@ in {
cfg.diff-so-fancy.enable
cfg.difftastic.enable
cfg.diff-highlight.enable
cfg.riff.enable
];
in count id enabled <= 1;
message =
@ -678,5 +702,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;
})
]);
}