mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-17 22:41:11 +01:00
zellij: Add extraConfig
This allows working around [#4659](https://github.com/nix-community/home-manager/issues/4659) While fixing `toKDL` might be fun, I just don't think it's a good use of anyone's time. --- This is still untested.
This commit is contained in:
parent
f59891d511
commit
9a2dc0efbc
3 changed files with 81 additions and 1 deletions
|
|
@ -178,6 +178,38 @@ in
|
||||||
list of options.
|
list of options.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
extraConfig = lib.mkOption {
|
||||||
|
description = ''
|
||||||
|
Extra configuration lines to add to `$XDG_CONFIG_HOME/zellij/config.kdl`.
|
||||||
|
|
||||||
|
This does not support zellij.yaml and it's mostly a workaround for https://github.com/nix-community/home-manager/issues/4659.
|
||||||
|
'';
|
||||||
|
type = lib.types.lines;
|
||||||
|
default = "";
|
||||||
|
example = ''
|
||||||
|
keybinds {
|
||||||
|
// keybinds are divided into modes
|
||||||
|
normal {
|
||||||
|
// bind instructions can include one or more keys (both keys will be bound separately)
|
||||||
|
// bind keys can include one or more actions (all actions will be performed with no sequential guarantees)
|
||||||
|
bind "Ctrl g" { SwitchToMode "locked"; }
|
||||||
|
bind "Ctrl p" { SwitchToMode "pane"; }
|
||||||
|
bind "Alt n" { NewPane; }
|
||||||
|
bind "Alt h" "Alt Left" { MoveFocusOrTab "Left"; }
|
||||||
|
}
|
||||||
|
pane {
|
||||||
|
bind "h" "Left" { MoveFocus "Left"; }
|
||||||
|
bind "l" "Right" { MoveFocus "Right"; }
|
||||||
|
bind "j" "Down" { MoveFocus "Down"; }
|
||||||
|
bind "k" "Up" { MoveFocus "Up"; }
|
||||||
|
bind "p" { SwitchFocus; }
|
||||||
|
}
|
||||||
|
locked {
|
||||||
|
bind "Ctrl g" { SwitchToMode "normal"; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
attachExistingSession = mkOption {
|
attachExistingSession = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
|
|
@ -240,6 +272,7 @@ in
|
||||||
# https://github.com/zellij-org/zellij/releases/tag/v0.32.0
|
# https://github.com/zellij-org/zellij/releases/tag/v0.32.0
|
||||||
xdg.configFile = lib.mkMerge [
|
xdg.configFile = lib.mkMerge [
|
||||||
{
|
{
|
||||||
|
|
||||||
"zellij/config.yaml" =
|
"zellij/config.yaml" =
|
||||||
mkIf (cfg.settings != { } && (lib.versionOlder cfg.package.version "0.32.0"))
|
mkIf (cfg.settings != { } && (lib.versionOlder cfg.package.version "0.32.0"))
|
||||||
{
|
{
|
||||||
|
|
@ -248,7 +281,16 @@ in
|
||||||
"zellij/config.kdl" =
|
"zellij/config.kdl" =
|
||||||
mkIf (cfg.settings != { } && (lib.versionAtLeast cfg.package.version "0.32.0"))
|
mkIf (cfg.settings != { } && (lib.versionAtLeast cfg.package.version "0.32.0"))
|
||||||
{
|
{
|
||||||
text = lib.hm.generators.toKDL { } cfg.settings;
|
text =
|
||||||
|
(lib.hm.generators.toKDL { } cfg.settings)
|
||||||
|
+ lib.optionalString (cfg.extraConfig != "") (
|
||||||
|
''
|
||||||
|
|
||||||
|
// extraConfig
|
||||||
|
|
||||||
|
''
|
||||||
|
+ cfg.extraConfig
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
37
tests/modules/programs/zellij/config.nix
Normal file
37
tests/modules/programs/zellij/config.nix
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs = {
|
||||||
|
zellij = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
default_layout = "welcome";
|
||||||
|
};
|
||||||
|
extraConfig = ''
|
||||||
|
This_could_have_been_json {
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
test.stubs = {
|
||||||
|
zellij = { };
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/zellij/config.kdl
|
||||||
|
|
||||||
|
assertFileContains \
|
||||||
|
home-files/.config/zellij/config.kdl \
|
||||||
|
'default_layout "welcome"'
|
||||||
|
|
||||||
|
assertFileContains \
|
||||||
|
home-files/.config/zellij/config.kdl \
|
||||||
|
'// extraConfig'
|
||||||
|
|
||||||
|
assertFileContains \
|
||||||
|
home-files/.config/zellij/config.kdl \
|
||||||
|
'This_could_have_been_json'
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
zellij-config = ./config.nix;
|
||||||
zellij-enable-shells = ./enable-shells.nix;
|
zellij-enable-shells = ./enable-shells.nix;
|
||||||
zellij-layout = ./layout.nix;
|
zellij-layout = ./layout.nix;
|
||||||
zellij-theme = ./theme.nix;
|
zellij-theme = ./theme.nix;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue