kitty: add environment and darwinLaunchOptions options (#2280)
* kitty: add environment option * kitty: add darwinLaunchOptions option See https://sw.kovidgoyal.net/kitty/faq/#how-do-i-specify-command-line-options-for-kitty-on-macos * kitty: only allow darwinLaunchOptions on darwin * kitty: make expression shorter * kitty: fix assertion message
This commit is contained in:
parent
f637e145d7
commit
33db7cc6a6
|
@ -25,10 +25,26 @@ let
|
||||||
mkKeyValue = key: command: "map ${key} ${command}";
|
mkKeyValue = key: command: "map ${key} ${command}";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
toKittyEnv =
|
||||||
|
generators.toKeyValue { mkKeyValue = name: value: "env ${name}=${value}"; };
|
||||||
|
|
||||||
in {
|
in {
|
||||||
options.programs.kitty = {
|
options.programs.kitty = {
|
||||||
enable = mkEnableOption "Kitty terminal emulator";
|
enable = mkEnableOption "Kitty terminal emulator";
|
||||||
|
|
||||||
|
darwinLaunchOptions = mkOption {
|
||||||
|
type = types.nullOr (types.listOf types.str);
|
||||||
|
default = null;
|
||||||
|
description = "Command-line options to use when launched by Mac OS GUI";
|
||||||
|
example = literalExample ''
|
||||||
|
[
|
||||||
|
"--single-instance"
|
||||||
|
"--directory=/tmp/my-dir"
|
||||||
|
"--listen-on=unix:/tmp/my-socket"
|
||||||
|
]
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
settings = mkOption {
|
settings = mkOption {
|
||||||
type = types.attrsOf eitherStrBoolInt;
|
type = types.attrsOf eitherStrBoolInt;
|
||||||
default = { };
|
default = { };
|
||||||
|
@ -65,6 +81,17 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
environment = mkOption {
|
||||||
|
type = types.attrsOf types.str;
|
||||||
|
default = { };
|
||||||
|
description = "Environment variables to set or override.";
|
||||||
|
example = literalExample ''
|
||||||
|
{
|
||||||
|
"LS_COLORS" = "1";
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
extraConfig = mkOption {
|
extraConfig = mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
|
@ -73,6 +100,14 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
assertions = [{
|
||||||
|
assertion = (cfg.darwinLaunchOptions != null)
|
||||||
|
-> pkgs.stdenv.hostPlatform.isDarwin;
|
||||||
|
message = ''
|
||||||
|
The 'programs.kitty.darwinLaunchOptions' option is only available on darwin.
|
||||||
|
'';
|
||||||
|
}];
|
||||||
|
|
||||||
home.packages = [ pkgs.kitty ] ++ optionalPackage cfg.font;
|
home.packages = [ pkgs.kitty ] ++ optionalPackage cfg.font;
|
||||||
|
|
||||||
xdg.configFile."kitty/kitty.conf".text = ''
|
xdg.configFile."kitty/kitty.conf".text = ''
|
||||||
|
@ -89,7 +124,14 @@ in {
|
||||||
|
|
||||||
${toKittyKeybindings cfg.keybindings}
|
${toKittyKeybindings cfg.keybindings}
|
||||||
|
|
||||||
|
${toKittyEnv cfg.environment}
|
||||||
|
|
||||||
${cfg.extraConfig}
|
${cfg.extraConfig}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
xdg.configFile."kitty/macos-launch-services-cmdline" =
|
||||||
|
mkIf (cfg.darwinLaunchOptions != null) {
|
||||||
|
text = concatStringsSep " " cfg.darwinLaunchOptions;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
--single-instance --directory=/tmp/my-dir --listen-on=unix:/tmp/my-socket
|
|
@ -14,4 +14,7 @@ map ctrl+c copy_or_interrupt
|
||||||
map ctrl+f>2 set_font_size 20
|
map ctrl+f>2 set_font_size 20
|
||||||
|
|
||||||
|
|
||||||
|
env LS_COLORS=1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,13 @@ with lib;
|
||||||
config = {
|
config = {
|
||||||
programs.kitty = {
|
programs.kitty = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
|
darwinLaunchOptions = lib.mkIf pkgs.stdenv.hostPlatform.isDarwin [
|
||||||
|
"--single-instance"
|
||||||
|
"--directory=/tmp/my-dir"
|
||||||
|
"--listen-on=unix:/tmp/my-socket"
|
||||||
|
];
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
scrollback_lines = 10000;
|
scrollback_lines = 10000;
|
||||||
enable_audio_bell = false;
|
enable_audio_bell = false;
|
||||||
|
@ -19,6 +26,8 @@ with lib;
|
||||||
"ctrl+c" = "copy_or_interrupt";
|
"ctrl+c" = "copy_or_interrupt";
|
||||||
"ctrl+f>2" = "set_font_size 20";
|
"ctrl+f>2" = "set_font_size 20";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
environment = { LS_COLORS = "1"; };
|
||||||
};
|
};
|
||||||
|
|
||||||
nixpkgs.overlays =
|
nixpkgs.overlays =
|
||||||
|
@ -29,6 +38,10 @@ with lib;
|
||||||
assertFileContent \
|
assertFileContent \
|
||||||
home-files/.config/kitty/kitty.conf \
|
home-files/.config/kitty/kitty.conf \
|
||||||
${./example-settings-expected.conf}
|
${./example-settings-expected.conf}
|
||||||
|
'' + lib.optionalString pkgs.stdenv.hostPlatform.isDarwin ''
|
||||||
|
assertFileContent \
|
||||||
|
home-files/.config/kitty/macos-launch-services-cmdline \
|
||||||
|
${./example-macos-launch-services-cmdline}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue