diff options
Diffstat (limited to 'home-manager/modules/programs/tmux.nix')
-rw-r--r-- | home-manager/modules/programs/tmux.nix | 98 |
1 files changed, 47 insertions, 51 deletions
diff --git a/home-manager/modules/programs/tmux.nix b/home-manager/modules/programs/tmux.nix index 766bc6238ba..a71c302ac6f 100644 --- a/home-manager/modules/programs/tmux.nix +++ b/home-manager/modules/programs/tmux.nix @@ -6,7 +6,7 @@ let cfg = config.programs.tmux; - pluginName = p: if types.package.check p then p.name else p.plugin.name; + pluginName = p: if types.package.check p then p.pname else p.plugin.pname; pluginModule = types.submodule { options = { @@ -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 { @@ -214,7 +251,7 @@ in }; secureSocket = mkOption { - default = true; + default = pkgs.stdenv.isLinux; type = types.bool; description = '' Store tmux socket under <filename>/run</filename>, which is more @@ -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; } + ]) ); } |