2020-03-28 22:48:43 -07:00
|
|
|
{ config, options, pkgs, lib, ... }:
|
2020-10-01 15:46:04 -07:00
|
|
|
|
2020-03-28 22:48:43 -07:00
|
|
|
with lib;
|
2020-10-01 15:46:04 -07:00
|
|
|
with lib.my;
|
|
|
|
let cfg = config.modules.shell.tmux;
|
2020-10-23 17:54:25 -07:00
|
|
|
# Despite tmux/tmux#142, tmux will support XDG in 3.2. Sadly, only 3.0 is
|
|
|
|
# available on nixpkgs, and 3.1b on master (tmux/tmux@15d7e56), so I
|
|
|
|
# implement it myself:
|
|
|
|
tmux = (pkgs.writeScriptBin "tmux" ''
|
|
|
|
#!${pkgs.stdenv.shell}
|
|
|
|
exec ${pkgs.tmux}/bin/tmux -f "$TMUX_HOME/config" "$@"
|
|
|
|
'');
|
2021-03-01 17:43:12 -08:00
|
|
|
configDir = config.dotfiles.configDir;
|
2020-10-01 15:46:04 -07:00
|
|
|
in {
|
2020-10-23 17:54:25 -07:00
|
|
|
options.modules.shell.tmux = with types; {
|
2020-10-01 15:46:04 -07:00
|
|
|
enable = mkBoolOpt false;
|
2020-10-23 17:54:25 -07:00
|
|
|
rcFiles = mkOpt (listOf (either str path)) [];
|
2020-03-28 22:48:43 -07:00
|
|
|
};
|
|
|
|
|
2020-10-01 15:46:04 -07:00
|
|
|
config = mkIf cfg.enable {
|
2020-10-23 17:54:25 -07:00
|
|
|
user.packages = [ tmux ];
|
|
|
|
|
|
|
|
modules.theme.onReload.tmux = "${tmux}/bin/tmux source-file $TMUX_HOME/extraInit";
|
2020-01-12 15:17:35 -08:00
|
|
|
|
2020-10-01 15:46:04 -07:00
|
|
|
modules.shell.zsh = {
|
|
|
|
rcInit = "_cache tmuxifier init -";
|
|
|
|
rcFiles = [ "${configDir}/tmux/aliases.zsh" ];
|
|
|
|
};
|
2020-01-12 15:17:35 -08:00
|
|
|
|
2020-10-01 15:46:04 -07:00
|
|
|
home.configFile = {
|
|
|
|
"tmux" = { source = "${configDir}/tmux"; recursive = true; };
|
2020-10-23 17:54:25 -07:00
|
|
|
"tmux/extraInit".text = ''
|
|
|
|
# This file is auto-generated by nixos, don't edit by hand!
|
2020-10-01 15:46:04 -07:00
|
|
|
run-shell ${pkgs.tmuxPlugins.copycat}/share/tmux-plugins/copycat/copycat.tmux
|
|
|
|
run-shell ${pkgs.tmuxPlugins.prefix-highlight}/share/tmux-plugins/prefix-highlight/prefix_highlight.tmux
|
|
|
|
run-shell ${pkgs.tmuxPlugins.yank}/share/tmux-plugins/yank/yank.tmux
|
2020-10-23 17:54:25 -07:00
|
|
|
|
|
|
|
${concatMapStrings (path: "source '${path}'\n") cfg.rcFiles}
|
2020-01-31 22:40:16 -08:00
|
|
|
'';
|
2020-10-01 15:46:04 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
env = {
|
|
|
|
PATH = [ "$TMUXIFIER/bin" ];
|
|
|
|
TMUX_HOME = "$XDG_CONFIG_HOME/tmux";
|
|
|
|
TMUXIFIER = "$XDG_DATA_HOME/tmuxifier";
|
|
|
|
TMUXIFIER_LAYOUT_PATH = "$XDG_DATA_HOME/tmuxifier";
|
2020-01-31 22:40:16 -08:00
|
|
|
};
|
2020-01-12 15:17:35 -08:00
|
|
|
};
|
|
|
|
}
|