1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 05:29:46 +01:00

kitty: allow not setting shell_integration

This allows better support for using kitty's built-in shell integration
method by setting `shellIntegration.mode' to `null', which makes it not
be set at all in the config file and disables modification to shell
initialization scripts by default. If this is used, the user should set
`settings.shell_integration' instead (if shell integration is desired),
which receives no special handling.
This commit is contained in:
MithicSpirit 2024-10-12 21:11:00 -04:00
parent d57112db87
commit 8f3d8dec26
No known key found for this signature in database
GPG key ID: 0EA043551EBD3C2E
4 changed files with 41 additions and 9 deletions

View file

@ -49,10 +49,11 @@ let
''; '';
}; };
shellIntegrationDefaultOpt = { shellIntegrationDefaultOpt = let mode = cfg.shellIntegration.mode;
default = !(elem "disabled" (splitString " " cfg.shellIntegration.mode)); in {
default = (mode != null) && !(elem "disabled" (splitString " " mode));
defaultText = literalExpression '' defaultText = literalExpression ''
!(elem "disabled" (splitString " " config.programs.kitty.shellIntegration.mode)) (mode != null) && !(elem "disabled" (splitString " " config.programs.kitty.shellIntegration.mode))
''; '';
}; };
in { in {
@ -162,18 +163,18 @@ in {
shellIntegration = { shellIntegration = {
mode = mkOption { mode = mkOption {
type = types.str; type = types.nullOr types.str;
default = "no-rc"; default = "no-rc";
example = "no-cursor"; example = "no-cursor";
apply = o: apply = mapNullable (o:
let let
modes = splitString " " o; modes = splitString " " o;
filtered = filter (m: m != "no-rc") modes; filtered = filter (m: m != "no-rc") modes;
in concatStringsSep " " (concatLists [ [ "no-rc" ] filtered ]); in concatStringsSep " " (concatLists [ [ "no-rc" ] filtered ]));
description = '' description = ''
Set the mode of the shell integration. This accepts the same options Set the mode of the shell integration. This accepts the same options
as the `shell_integration` option of Kitty. Note that 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
<https://sw.kovidgoyal.net/kitty/shell-integration> <https://sw.kovidgoyal.net/kitty/shell-integration>
for more details. for more details.
''; '';
@ -213,10 +214,10 @@ in {
(optionalString (cfg.themeFile != null) '' (optionalString (cfg.themeFile != null) ''
include ${pkgs.kitty-themes}/share/kitty-themes/themes/${cfg.themeFile}.conf 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 is sourced and configured manually
shell_integration ${cfg.shellIntegration.mode} shell_integration ${cfg.shellIntegration.mode}
'' '')
(toKittyConfig cfg.settings) (toKittyConfig cfg.settings)
(toKittyKeybindings cfg.keybindings) (toKittyKeybindings cfg.keybindings)
(toKittyEnv cfg.environment) (toKittyEnv cfg.environment)

View file

@ -1,4 +1,5 @@
{ {
kitty-example-settings = ./example-settings.nix; kitty-example-settings = ./example-settings.nix;
kitty-theme-to-themeFile = ./theme-to-themeFile.nix; kitty-theme-to-themeFile = ./theme-to-themeFile.nix;
kitty-null-shellIntegration = ./null-shellIntegration.nix;
} }

View file

@ -0,0 +1,8 @@
# Generated by Home Manager.
# See https://sw.kovidgoyal.net/kitty/conf.html

View file

@ -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}
'';
};
}