diff --git a/modules/programs/kitty.nix b/modules/programs/kitty.nix index 9854fe69c..3d279c037 100644 --- a/modules/programs/kitty.nix +++ b/modules/programs/kitty.nix @@ -49,10 +49,11 @@ let ''; }; - shellIntegrationDefaultOpt = { - default = !(elem "disabled" (splitString " " cfg.shellIntegration.mode)); + shellIntegrationDefaultOpt = let mode = cfg.shellIntegration.mode; + in { + default = (mode != null) && !(elem "disabled" (splitString " " mode)); defaultText = literalExpression '' - !(elem "disabled" (splitString " " config.programs.kitty.shellIntegration.mode)) + (mode != null) && !(elem "disabled" (splitString " " config.programs.kitty.shellIntegration.mode)) ''; }; in { @@ -162,18 +163,18 @@ in { shellIntegration = { mode = mkOption { - type = types.str; + type = types.nullOr types.str; default = "no-rc"; example = "no-cursor"; - apply = o: + apply = mapNullable (o: let modes = splitString " " o; filtered = filter (m: m != "no-rc") modes; - in concatStringsSep " " (concatLists [ [ "no-rc" ] filtered ]); + in concatStringsSep " " (concatLists [ [ "no-rc" ] filtered ])); description = '' Set the mode of the shell integration. This accepts the same options as the `shell_integration` option of Kitty. Note that - `no-rc` is always implied. See + `no-rc` is always implied, unless this set to `null`. See for more details. ''; @@ -213,10 +214,10 @@ in { (optionalString (cfg.themeFile != null) '' include ${pkgs.kitty-themes}/share/kitty-themes/themes/${cfg.themeFile}.conf '') - '' + (optionalString (cfg.shellIntegration.mode != null) '' # Shell integration is sourced and configured manually shell_integration ${cfg.shellIntegration.mode} - '' + '') (toKittyConfig cfg.settings) (toKittyKeybindings cfg.keybindings) (toKittyEnv cfg.environment) diff --git a/tests/modules/programs/kitty/default.nix b/tests/modules/programs/kitty/default.nix index 76016d516..054353e43 100644 --- a/tests/modules/programs/kitty/default.nix +++ b/tests/modules/programs/kitty/default.nix @@ -1,4 +1,5 @@ { kitty-example-settings = ./example-settings.nix; kitty-theme-to-themeFile = ./theme-to-themeFile.nix; + kitty-null-shellIntegration = ./null-shellIntegration.nix; } diff --git a/tests/modules/programs/kitty/null-shellIntegration-expected.conf b/tests/modules/programs/kitty/null-shellIntegration-expected.conf new file mode 100644 index 000000000..df3ae5984 --- /dev/null +++ b/tests/modules/programs/kitty/null-shellIntegration-expected.conf @@ -0,0 +1,8 @@ +# Generated by Home Manager. +# See https://sw.kovidgoyal.net/kitty/conf.html + + + + + + diff --git a/tests/modules/programs/kitty/null-shellIntegration.nix b/tests/modules/programs/kitty/null-shellIntegration.nix new file mode 100644 index 000000000..293249d69 --- /dev/null +++ b/tests/modules/programs/kitty/null-shellIntegration.nix @@ -0,0 +1,22 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.kitty = { + enable = true; + + shellIntegration.mode = null; + }; + + test.stubs.kitty = { }; + + nmt.script = '' + assertFileExists home-files/.config/kitty/kitty.conf + assertFileContent \ + home-files/.config/kitty/kitty.conf \ + ${./null-shellIntegration-expected.conf} + ''; + }; +}