1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-01 04:23:34 +02:00

tmux: Add extraConfigBeforePlugins to tmux.config

Adds the possibility to add config before the plugins are loaded
This commit is contained in:
Gabriel Nützi 2023-11-17 18:29:27 +01:00
parent c1a033122d
commit 898a1cef2d
4 changed files with 84 additions and 7 deletions

View File

@ -1,9 +1,6 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.tmux;
pluginName = p: if types.package.check p then p.pname else p.plugin.pname;
@ -127,7 +124,6 @@ let
# ============================================= #
'';
};
in {
options = {
programs.tmux = {
@ -191,6 +187,15 @@ in {
'';
};
extraConfigBeforePlugins = mkOption {
type = types.lines;
default = "";
description = ''
Additional configuration to add to
{file}`tmux.conf` before the plugins.
'';
};
historyLimit = mkOption {
default = 2000;
example = 5000;
@ -324,7 +329,7 @@ in {
};
};
config = mkIf cfg.enable (mkMerge ([
config = mkIf cfg.enable (mkMerge [
{
home.packages = [ cfg.package ]
++ optional cfg.tmuxinator.enable pkgs.tmuxinator
@ -332,7 +337,6 @@ in {
}
{ xdg.configFile."tmux/tmux.conf".text = mkBefore tmuxConf; }
{ xdg.configFile."tmux/tmux.conf".text = mkAfter cfg.extraConfig; }
(mkIf cfg.secureSocket {
home.sessionVariables = {
@ -340,6 +344,11 @@ in {
};
})
{
xdg.configFile."tmux/tmux.conf".text =
mkAfter cfg.extraConfigBeforePlugins;
}
(mkIf (cfg.plugins != [ ]) configPlugins)
]));
{ xdg.configFile."tmux/tmux.conf".text = cfg.extraConfig; }
]);
}

View File

@ -8,4 +8,5 @@
tmux-shortcut-without-prefix = ./shortcut-without-prefix.nix;
tmux-prefix = ./prefix.nix;
tmux-mouse-enabled = ./mouse-enabled.nix;
tmux-extra-config-before-plugins = ./extra-config-before-plugins.nix;
}

View File

@ -0,0 +1,39 @@
# ============================================= #
# Start with defaults from the Sensible plugin #
# --------------------------------------------- #
run-shell @sensible_rtp@
# ============================================= #
set -g default-terminal "screen"
set -g base-index 0
setw -g pane-base-index 0
set -g status-keys emacs
set -g mode-keys emacs
set -g mouse on
setw -g aggressive-resize off
setw -g clock-mode-style 12
set -s escape-time 500
set -g history-limit 2000
set -g mouse off
# ============================================= #
# Load plugins with Home Manager #
# --------------------------------------------- #
# tmuxplugin-logging
# ---------------------
run-shell @tmuxplugin_logging_rtp@
# ============================================= #

View File

@ -0,0 +1,28 @@
{ config, lib, pkgs, ... }:
with lib; {
config = {
programs.tmux = {
enable = true;
mouse = true;
extraConfigBeforePlugins = ''
set -g mouse off
'';
plugins = with pkgs.tmuxPlugins; [ logging ];
};
nixpkgs.overlays = [
(self: super: {
tmuxPlugins = super.tmuxPlugins // {
sensible = super.tmuxPlugins.sensible // { rtp = "@sensible_rtp@"; };
};
})
];
nmt.script = ''
assertFileExists home-files/.config/tmux/tmux.conf
assertFileContent home-files/.config/tmux/tmux.conf \
${./mouse-enabled.conf}
'';
};
}