From ae24ae14009ad5e64abae7b9908d5c2f7beb4e8c Mon Sep 17 00:00:00 2001 From: matt1432 Date: Fri, 22 Nov 2024 16:10:51 -0500 Subject: [PATCH] refactor: move tmux to nixosModules --- common/default.nix | 3 ++ common/home/default.nix | 1 - common/home/tmux/default.nix | 31 ------------------ flake.lock | Bin 55022 -> 55022 bytes nixosModules/default.nix | 1 + nixosModules/tmux/default.nix | 58 ++++++++++++++++++++++++++++++++++ 6 files changed, 62 insertions(+), 32 deletions(-) delete mode 100644 common/home/tmux/default.nix create mode 100644 nixosModules/tmux/default.nix diff --git a/common/default.nix b/common/default.nix index 4261c87d..d224870a 100644 --- a/common/default.nix +++ b/common/default.nix @@ -17,6 +17,9 @@ in { ./packages.nix self.nixosModules.borgbackup + self.nixosModules.tmux + {programs.tmux.enableCustomConf = true;} + home-manager.nixosModules.home-manager ]; diff --git a/common/home/default.nix b/common/home/default.nix index 614d3fb0..59556063 100644 --- a/common/home/default.nix +++ b/common/home/default.nix @@ -4,6 +4,5 @@ ./direnv ./git ./nix-index - ./tmux ]; } diff --git a/common/home/tmux/default.nix b/common/home/tmux/default.nix deleted file mode 100644 index 560b1b21..00000000 --- a/common/home/tmux/default.nix +++ /dev/null @@ -1,31 +0,0 @@ -{pkgs, ...}: { - programs = { - # Make sure we have color support - bash.shellAliases.tmux = "tmux -2"; - - tmux = { - enable = true; - mouse = true; - keyMode = "vi"; - terminal = "tmux-256color"; - newSession = true; - historyLimit = 30000; - - plugins = builtins.attrValues { - inherit (pkgs.tmuxPlugins) dracula; - }; - - extraConfig = - # bash - '' - bind-key -n Home send Escape "OH" - bind-key -n End send Escape "OF" - bind -T root WheelUpPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; copy-mode -e; send-keys -M" - bind -T root WheelDownPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; send-keys -M" - - set -ga terminal-overrides ',xterm*:smcup@:rmcup@' - set -ga terminal-overrides ",*256col*:Tc" - ''; - }; - }; -} diff --git a/flake.lock b/flake.lock index 9ac773be05a9f8eef1fb63d3073bb101d92b218d..906b5b734750aa2af4a28c253637c36b7166f088 100644 GIT binary patch delta 131 zcmaF2migUU<_$_o9L7e*1{UUKW|J3s$!dEAg}O#KMVW!FD?cEAZ;pg delta 127 zcmV-_0D%AQtpo0@1F#}u2Qo4B``Vlgr@HDqOBG?VdEXR}LVqjS8_Dlq^6 diff --git a/nixosModules/default.nix b/nixosModules/default.nix index d12d9d80..2566f121 100644 --- a/nixosModules/default.nix +++ b/nixosModules/default.nix @@ -9,5 +9,6 @@ self: { nvidia = import ./nvidia; plymouth = import ./plymouth; server = import ./server; + tmux = import ./tmux; wyoming-plus = import ./wyoming-plus; } diff --git a/nixosModules/tmux/default.nix b/nixosModules/tmux/default.nix new file mode 100644 index 00000000..c0c0a289 --- /dev/null +++ b/nixosModules/tmux/default.nix @@ -0,0 +1,58 @@ +{ + config, + lib, + pkgs, + ... +}: let + inherit (lib) attrValues elemAt mkIf mkOption types; + + cfg = config.programs.tmux; + + firstUser = elemAt (attrValues config.home-manager.users) 0; +in { + options.programs.tmux = { + enableCustomConf = mkOption { + type = types.bool; + default = false; + }; + }; + + config = mkIf cfg.enableCustomConf { + environment.etc."tmux.conf".source = firstUser.xdg.configFile."tmux/tmux.conf".source; + + home-manager.sharedModules = [ + { + programs = { + # Make sure we have color support + bash.shellAliases.tmux = "tmux -2"; + + tmux = { + enable = true; + mouse = true; + keyMode = "vi"; + terminal = "tmux-256color"; + newSession = true; + historyLimit = 30000; + + plugins = attrValues { + inherit (pkgs.tmuxPlugins) dracula; + }; + + extraConfig = + # bash + '' + bind-key -n Home send Escape "OH" + bind-key -n End send Escape "OF" + + bind -T root WheelUpPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; copy-mode -e; send-keys -M" + bind -T root WheelDownPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; send-keys -M" + + set -ga terminal-overrides ',xterm*:smcup@:rmcup@' + set -ga terminal-overrides ",*256col*:Tc" + ''; + }; + }; + } + ]; + }; +}