From 7d3d323e906a06247920c0a8fb2fa473a3770fb9 Mon Sep 17 00:00:00 2001 From: Brian Lyles Date: Thu, 2 Oct 2025 23:53:56 -0500 Subject: [PATCH] git: add `extraArgs` option for difftastic This option will cover any other arguments that aren't made available with dedicated options. --- modules/programs/git.nix | 29 ++++++++++++++----- .../programs/git/git-difftastic-expected.conf | 4 +-- tests/modules/programs/git/git-difftastic.nix | 4 +++ 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/modules/programs/git.nix b/modules/programs/git.nix index 2a0bbad76..94a65747f 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -377,6 +377,18 @@ in Determines how the output displays - in one column or two columns. ''; }; + + extraArgs = mkOption { + type = types.nullOr (types.listOf types.str); + default = null; + example = [ + "--tab-width=8" + "--sort-paths" + ]; + description = '' + Extra command line arguments to pass to {command}`difft`. + ''; + }; }; delta = { @@ -837,13 +849,16 @@ in ( let - difftCommand = concatStringsSep " " [ - "${lib.getExe cfg.difftastic.package}" - "--color ${cfg.difftastic.color}" - "--background ${cfg.difftastic.background}" - "--display ${cfg.difftastic.display}" - "--context ${toString cfg.difftastic.context}" - ]; + difftCommand = concatStringsSep " " ( + [ + "${lib.getExe cfg.difftastic.package}" + "--color ${cfg.difftastic.color}" + "--background ${cfg.difftastic.background}" + "--display ${cfg.difftastic.display}" + "--context ${toString cfg.difftastic.context}" + ] + ++ (lib.optionals (cfg.difftastic.extraArgs != null) cfg.difftastic.extraArgs) + ); in (lib.mkMerge [ (mkIf cfg.difftastic.enable { diff --git a/tests/modules/programs/git/git-difftastic-expected.conf b/tests/modules/programs/git/git-difftastic-expected.conf index 80c6ba6f0..3603fca31 100644 --- a/tests/modules/programs/git/git-difftastic-expected.conf +++ b/tests/modules/programs/git/git-difftastic-expected.conf @@ -1,9 +1,9 @@ [diff] - external = "@difftastic@/bin/difft --color always --background dark --display inline --context 5" + external = "@difftastic@/bin/difft --color always --background dark --display inline --context 5 --tab-width=8 --sort-paths" tool = "difftastic" [difftool "difftastic"] - cmd = "@difftastic@/bin/difft --color always --background dark --display inline --context 5 $LOCAL $REMOTE" + cmd = "@difftastic@/bin/difft --color always --background dark --display inline --context 5 --tab-width=8 --sort-paths $LOCAL $REMOTE" [gpg] format = "openpgp" diff --git a/tests/modules/programs/git/git-difftastic.nix b/tests/modules/programs/git/git-difftastic.nix index c28e3f263..20fa50c2e 100644 --- a/tests/modules/programs/git/git-difftastic.nix +++ b/tests/modules/programs/git/git-difftastic.nix @@ -9,6 +9,10 @@ color = "always"; context = 5; display = "inline"; + extraArgs = [ + "--tab-width=8" + "--sort-paths" + ]; }; };