Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions modules/programs/git.nix
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,34 @@ in {
};
};

difftastic = {
enable = mkEnableOption "" // {
description = ''
Enable the <command>difft</command> syntax highlighter.
See <link xlink:href="https://github.com/Wilfred/difftastic" />.
'';
};

background = mkOption {
Comment thread
sumnerevans marked this conversation as resolved.
type = types.enum [ "light" "dark" ];
default = "light";
example = "dark";
description = ''
Determines whether difftastic should use the lighter or darker colors
for syntax highlithing.
'';
};

color = mkOption {
type = types.enum [ "always" "auto" "never" ];
default = "auto";
example = "always";
description = ''
Determines when difftastic should color its output.
'';
};
};

delta = {
enable = mkEnableOption "" // {
description = ''
Expand Down Expand Up @@ -274,6 +302,11 @@ in {
config = mkIf cfg.enable (mkMerge [
{
home.packages = [ cfg.package ];
assertions = [{
assertion = !(cfg.delta.enable && cfg.difftastic.enable);
message =
"Only one of 'programs.git.delta.enable' or 'programs.git.difftastic.enable' can be set to true at the same time.";
}];

programs.git.iniContent.user = {
name = mkIf (cfg.userName != null) cfg.userName;
Expand Down Expand Up @@ -377,6 +410,18 @@ in {
};
})

(mkIf cfg.difftastic.enable {
Comment thread
sumnerevans marked this conversation as resolved.
home.packages = [ pkgs.difftastic ];

programs.git.iniContent = let
difftCommand =
"${pkgs.difftastic}/bin/difft --color ${cfg.difftastic.color} --background ${cfg.difftastic.background}";
in {
diff.external = difftCommand;
core.pager = "${pkgs.less}/bin/less -XF";
};
})

(mkIf cfg.delta.enable {
home.packages = [ pkgs.delta ];

Expand Down