From 564bc37de50075e03ccfba5dc894ae25804ef3ce Mon Sep 17 00:00:00 2001 From: Rachit Kumar Verma <155641117+rachitvrma@users.noreply.github.com> Date: Sat, 11 Jul 2026 16:19:33 +0530 Subject: [PATCH] kitty: fix diff.conf being generated regardless of user config 'cfg.diffConfig' is an implicit submodule with sub-options that carry their own defaults, so it never actually equals `{ }` - the previous `cfg.diffConfig != { }` check was always true. This caused 'kitty/diff.conf' to be written (and clobber any existing unmanaged file) even when the user configured nothing under `programs.kitty.diffConfig`. --- modules/programs/kitty.nix | 2 +- tests/modules/programs/kitty/default.nix | 1 + .../kitty/example-diffConfig-expected.conf | 6 ++++++ .../programs/kitty/example-diffConfig.nix | 21 +++++++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 tests/modules/programs/kitty/example-diffConfig-expected.conf create mode 100644 tests/modules/programs/kitty/example-diffConfig.nix diff --git a/modules/programs/kitty.nix b/modules/programs/kitty.nix index e2a75fc7d6..9484485581 100644 --- a/modules/programs/kitty.nix +++ b/modules/programs/kitty.nix @@ -433,7 +433,7 @@ in ''; }; - xdg.configFile."kitty/diff.conf" = mkIf (cfg.diffConfig != { }) { + xdg.configFile."kitty/diff.conf" = mkIf (cfg.diffConfig.extraConfig != "") { text = '' # Generated by Home Manager # See https://sw.kovidgoyal.net/kitty/kittens/diff/ diff --git a/tests/modules/programs/kitty/default.nix b/tests/modules/programs/kitty/default.nix index 789650367a..1c0fce4157 100644 --- a/tests/modules/programs/kitty/default.nix +++ b/tests/modules/programs/kitty/default.nix @@ -5,4 +5,5 @@ kitty-example-mkOrder = ./example-mkOrder.nix; kitty-example-quickAccessTerminalConfig = ./example-quickAccessTerminalConfig.nix; kitty-auto-theme-files = ./auto-theme-files.nix; + kitty-example-diffConfig = ./example-diffConfig.nix; } diff --git a/tests/modules/programs/kitty/example-diffConfig-expected.conf b/tests/modules/programs/kitty/example-diffConfig-expected.conf new file mode 100644 index 0000000000..6ff2ebcc16 --- /dev/null +++ b/tests/modules/programs/kitty/example-diffConfig-expected.conf @@ -0,0 +1,6 @@ +# Generated by Home Manager +# See https://sw.kovidgoyal.net/kitty/kittens/diff/ +diff_cmd auto + +map j scroll_by 1 + diff --git a/tests/modules/programs/kitty/example-diffConfig.nix b/tests/modules/programs/kitty/example-diffConfig.nix new file mode 100644 index 0000000000..e2040a76b7 --- /dev/null +++ b/tests/modules/programs/kitty/example-diffConfig.nix @@ -0,0 +1,21 @@ +{ + config = { + programs.kitty = { + enable = true; + + diffConfig = { + settings.diff_cmd = "auto"; + keybindings = { + "j" = "scroll_by 1"; + }; + }; + }; + + nmt.script = '' + assertFileExists home-files/.config/kitty/diff.conf + assertFileContent \ + home-files/.config/kitty/diff.conf \ + ${./example-diffConfig-expected.conf} + ''; + }; +}