1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-28 04:39:48 +01:00

tmux: reorder tmux.conf content

In particular, put `extraConfig` in the end, which enables overriding
of all settings, even plugin settings.

PR #945
This commit is contained in:
Johannes Rosenberger 2020-04-25 17:02:49 +02:00 committed by Robert Helgesson
parent a6037a9eb8
commit a7cdfaa325
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
4 changed files with 46 additions and 53 deletions

View file

@ -31,6 +31,13 @@ let
boolToStr = value: if value then "on" else "off";
tmuxConf = ''
${optionalString cfg.sensibleOnTop ''
# ============================================= #
# Start with defaults from the Sensible plugin #
# --------------------------------------------- #
run-shell ${pkgs.tmuxPlugins.sensible.rtp}
# ============================================= #
''}
set -g default-terminal "${cfg.terminal}"
set -g base-index ${toString cfg.baseIndex}
setw -g pane-base-index ${toString cfg.baseIndex}
@ -74,10 +81,40 @@ let
setw -g clock-mode-style ${if cfg.clock24 then "24" else "12"}
set -s escape-time ${toString cfg.escapeTime}
set -g history-limit ${toString cfg.historyLimit}
${cfg.extraConfig}
'';
configPlugins = {
assertions = [(
let
hasBadPluginName = p: !(hasPrefix "tmuxplugin" (pluginName p));
badPlugins = filter hasBadPluginName cfg.plugins;
in
{
assertion = badPlugins == [];
message =
"Invalid tmux plugin (not prefixed with \"tmuxplugins\"): "
+ concatMapStringsSep ", " pluginName badPlugins;
}
)];
home.file.".tmux.conf".text = ''
# ============================================= #
# Load plugins with Home Manager #
# --------------------------------------------- #
${(concatMapStringsSep "\n\n" (p: ''
# ${pluginName p}
# ---------------------
${p.extraConfig or ""}
run-shell ${
if types.package.check p
then p.rtp
else p.plugin.rtp
}
'') cfg.plugins)}
# ============================================= #
'';
};
in
{
@ -258,63 +295,22 @@ in
};
config = mkIf cfg.enable (
mkMerge [
mkMerge ([
{
home.packages = [ cfg.package ]
++ optional cfg.tmuxinator.enable pkgs.tmuxinator
++ optional cfg.tmuxp.enable pkgs.tmuxp;
home.file.".tmux.conf".text = tmuxConf;
}
(mkIf cfg.sensibleOnTop {
home.file.".tmux.conf".text = mkBefore ''
# ============================================= #
# Start with defaults from the Sensible plugin #
# --------------------------------------------- #
run-shell ${pkgs.tmuxPlugins.sensible.rtp}
# ============================================= #
'';
})
(mkIf cfg.secureSocket {
home.sessionVariables = {
TMUX_TMPDIR = ''''${XDG_RUNTIME_DIR:-"/run/user/\$(id -u)"}'';
};
})
(mkIf (cfg.plugins != []) {
assertions = [(
let
hasBadPluginName = p: !(hasPrefix "tmuxplugin" (pluginName p));
badPlugins = filter hasBadPluginName cfg.plugins;
in
{
assertion = badPlugins == [];
message =
"Invalid tmux plugin (not prefixed with \"tmuxplugins\"): "
+ concatMapStringsSep ", " pluginName badPlugins;
}
)];
home.file.".tmux.conf".text = mkAfter ''
# ============================================= #
# Load plugins with Home Manager #
# --------------------------------------------- #
${(concatMapStringsSep "\n\n" (p: ''
# ${pluginName p}
# ---------------------
${p.extraConfig or ""}
run-shell ${
if types.package.check p
then p.rtp
else p.plugin.rtp
}
'') cfg.plugins)}
# ============================================= #
'';
})
]
# config file ~/.tmux.conf
{ home.file.".tmux.conf".text = mkBefore tmuxConf; }
(mkIf (cfg.plugins != []) configPlugins)
{ home.file.".tmux.conf".text = mkAfter cfg.extraConfig; }
])
);
}

View file

@ -28,4 +28,3 @@ setw -g clock-mode-style 12
set -s escape-time 500
set -g history-limit 2000

View file

@ -28,8 +28,6 @@ setw -g clock-mode-style 24
set -s escape-time 500
set -g history-limit 2000
# ============================================= #
# Load plugins with Home Manager #
# --------------------------------------------- #
@ -52,3 +50,4 @@ run-shell @tmuxplugin_prefix_highlight_rtp@
run-shell @tmuxplugin_fzf_tmux_url_rtp@
# ============================================= #

View file

@ -28,4 +28,3 @@ setw -g clock-mode-style 24
set -s escape-time 500
set -g history-limit 2000