From 705c3ce8000825aac198c0691e65d010d8652176 Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Sat, 24 Feb 2024 21:44:25 +0300 Subject: [PATCH] Tmux : Move config to nix. --- .config/linux/system/flake.nix | 2 +- .../system/host/laptop/Configuration.nix | 7 +- .../system/module/common/Environment.nix | 5 + .config/linux/system/module/common/Neovim.nix | 7 -- .../linux/system/module/common/Package.nix | 4 +- .config/linux/system/module/common/Tmux.nix | 26 +++++ .../system/module/common/tmux/Buffer.nix | 17 ++++ .../system/module/common/tmux/Environment.nix | 6 ++ .../linux/system/module/common/tmux/Pane.nix | 24 +++++ .../system/module/common/tmux/Session.nix | 15 +++ .../system/module/common/tmux/Statusbar.nix | 22 +++++ .../system/module/common/tmux/Window.nix | 19 ++++ .config/tmux/tmux.conf | 95 ------------------- .gitignore | 4 - .../com.github.iwalton3.jellyfin-media-player | 2 - .../flatpak/overrides/com.usebottles.bottles | 7 -- .../flatpak/overrides/com.valvesoftware.Steam | 9 -- .local/share/flatpak/overrides/global | 2 - .local/share/flatpak/overrides/io.mpv.Mpv | 2 - .../flatpak/overrides/org.blender.Blender | 6 -- .../share/flatpak/overrides/org.kde.kdenlive | 2 - .../flatpak/overrides/org.mozilla.Thunderbird | 2 - .../flatpak/overrides/org.mozilla.firefox | 3 - 23 files changed, 143 insertions(+), 145 deletions(-) delete mode 100644 .config/linux/system/module/common/Neovim.nix create mode 100644 .config/linux/system/module/common/Tmux.nix create mode 100644 .config/linux/system/module/common/tmux/Buffer.nix create mode 100644 .config/linux/system/module/common/tmux/Environment.nix create mode 100644 .config/linux/system/module/common/tmux/Pane.nix create mode 100644 .config/linux/system/module/common/tmux/Session.nix create mode 100644 .config/linux/system/module/common/tmux/Statusbar.nix create mode 100644 .config/linux/system/module/common/tmux/Window.nix delete mode 100644 .config/tmux/tmux.conf delete mode 100644 .local/share/flatpak/overrides/com.github.iwalton3.jellyfin-media-player delete mode 100644 .local/share/flatpak/overrides/com.usebottles.bottles delete mode 100644 .local/share/flatpak/overrides/com.valvesoftware.Steam delete mode 100644 .local/share/flatpak/overrides/global delete mode 100644 .local/share/flatpak/overrides/io.mpv.Mpv delete mode 100644 .local/share/flatpak/overrides/org.blender.Blender delete mode 100644 .local/share/flatpak/overrides/org.kde.kdenlive delete mode 100644 .local/share/flatpak/overrides/org.mozilla.Thunderbird delete mode 100644 .local/share/flatpak/overrides/org.mozilla.firefox diff --git a/.config/linux/system/flake.nix b/.config/linux/system/flake.nix index c7af9bd..6f959f7 100644 --- a/.config/linux/system/flake.nix +++ b/.config/linux/system/flake.nix @@ -26,13 +26,13 @@ ./module/common/Git.nix ./module/common/Kernel.nix ./module/common/Locale.nix - ./module/common/Neovim.nix ./module/common/Network.nix ./module/common/Nix.nix ./module/common/Package.nix ./module/common/Root.nix ./module/common/Sshd.nix ./module/common/Swap.nix + ./module/common/Tmux.nix ./module/common/Users.nix ./module/common/Wallpaper.nix ]; diff --git a/.config/linux/system/host/laptop/Configuration.nix b/.config/linux/system/host/laptop/Configuration.nix index da0269b..bb138c8 100644 --- a/.config/linux/system/host/laptop/Configuration.nix +++ b/.config/linux/system/host/laptop/Configuration.nix @@ -1,6 +1,11 @@ -{ config, pkgs, ... }: { +{ config, pkgs, environment, ... }: { imports = [ ]; + # Use dedicated GPU by default. + environment.variables = { + DRI_PRIME = 1; + }; + # Filesystems. fileSystems."/storage/hot" = { device = "/dev/storage/hot"; diff --git a/.config/linux/system/module/common/Environment.nix b/.config/linux/system/module/common/Environment.nix index ef56996..40da499 100644 --- a/.config/linux/system/module/common/Environment.nix +++ b/.config/linux/system/module/common/Environment.nix @@ -1,7 +1,12 @@ { environment, ... }: { security.loginDefs.settings.UMASK = "077"; environment.variables = { + # Neovim. EDITOR = "nvim"; MANPAGER = "nvim +Man!"; + + # Mangohud. + MANGOHUD = "true"; + MANGOHUD_CONFIGFILE = "~/.config/MangoHud/MangoHud.conf"; }; } diff --git a/.config/linux/system/module/common/Neovim.nix b/.config/linux/system/module/common/Neovim.nix deleted file mode 100644 index 27e28cf..0000000 --- a/.config/linux/system/module/common/Neovim.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ ... }: { - programs.neovim = { - enable = true; - viAlias = true; - vimAlias = true; - }; -} diff --git a/.config/linux/system/module/common/Package.nix b/.config/linux/system/module/common/Package.nix index 48ff1a7..3118d93 100644 --- a/.config/linux/system/module/common/Package.nix +++ b/.config/linux/system/module/common/Package.nix @@ -30,7 +30,6 @@ sqlite steam-run testdisk - tmux tree ventoy wget @@ -40,5 +39,6 @@ ]; # Special packages. - programs.adb.enable = true; + programs.adb.enable = true; + programs.neovim.enable = true; } diff --git a/.config/linux/system/module/common/Tmux.nix b/.config/linux/system/module/common/Tmux.nix new file mode 100644 index 0000000..e9a6a60 --- /dev/null +++ b/.config/linux/system/module/common/Tmux.nix @@ -0,0 +1,26 @@ +{ ... }: { + imports = [ + ./tmux/Buffer.nix + ./tmux/Environment.nix + ./tmux/Pane.nix + ./tmux/Session.nix + ./tmux/Statusbar.nix + ./tmux/Window.nix + ]; + + programs.tmux = { + enable = true; + extraConfig = '' + # Remap to . + unbind-key C-b + set-option -g prefix C-t + bind-key C-t send-prefix + + # Disable escape delay. + set -sg escape-time 0 + + # Reload config. + bind -n M-r source-file /etc/tmux.conf + ''; + }; +} diff --git a/.config/linux/system/module/common/tmux/Buffer.nix b/.config/linux/system/module/common/tmux/Buffer.nix new file mode 100644 index 0000000..fa9c92e --- /dev/null +++ b/.config/linux/system/module/common/tmux/Buffer.nix @@ -0,0 +1,17 @@ +{ ... }: { + programs.tmux.extraConfig = '' + # Scroll. + bind -n M-p copy-mode -u + bind -n M-n send-keys Pagedown + + # Copy mode. + setw -g mode-keys vi + bind -n M-v copy-mode + bind -n M-P choose-buffer + bind -T copy-mode-vi v send -X begin-selection + bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy" + + # Selection style. + set -g mode-style 'fg=black,bg=yellow bold' + ''; +} diff --git a/.config/linux/system/module/common/tmux/Environment.nix b/.config/linux/system/module/common/tmux/Environment.nix new file mode 100644 index 0000000..9c9a997 --- /dev/null +++ b/.config/linux/system/module/common/tmux/Environment.nix @@ -0,0 +1,6 @@ +{ ... }: { + programs.tmux.extraConfig = '' + # Update environment from client. + set-option -g update-environment "SSH_CLIENT SSH_TTY DOCKER_CONFIG DOCKER_HOST DISPLAY XAUTHORITY" + ''; +} diff --git a/.config/linux/system/module/common/tmux/Pane.nix b/.config/linux/system/module/common/tmux/Pane.nix new file mode 100644 index 0000000..adb3be6 --- /dev/null +++ b/.config/linux/system/module/common/tmux/Pane.nix @@ -0,0 +1,24 @@ +{ ... }: { + programs.tmux.extraConfig = '' + # Remap split keys. + bind -n M-\\ split-window -h -c "#{pane_current_path}" + bind -n M-- split-window -v -c "#{pane_current_path}" + bind -n M-= select-layout tiled + bind -n M-W resize-pane -U 1 + bind -n M-S resize-pane -D 1 + bind -n M-A resize-pane -L 1 + bind -n M-D resize-pane -R 1 + unbind '"' + unbind % + + # Swith panes with alt + hjkl. + bind -n M-a select-pane -L + bind -n M-d select-pane -R + bind -n M-w select-pane -U + bind -n M-s select-pane -D + + # Close pane. + bind -n M-c kill-pane + bind -n M-C kill-pane -a + ''; +} diff --git a/.config/linux/system/module/common/tmux/Session.nix b/.config/linux/system/module/common/tmux/Session.nix new file mode 100644 index 0000000..220f486 --- /dev/null +++ b/.config/linux/system/module/common/tmux/Session.nix @@ -0,0 +1,15 @@ +{ ... }: { + programs.tmux.extraConfig = '' + # Detach. + bind -n M-z detach-client + bind -n M-Z detach-client -a + + # Switch sessions. + bind -n M-9 switch-client -p + bind -n M-0 switch-client -n + bind -n M-g choose-session + + # Resize to smallest client. + set -g window-size smallest + ''; +} diff --git a/.config/linux/system/module/common/tmux/Statusbar.nix b/.config/linux/system/module/common/tmux/Statusbar.nix new file mode 100644 index 0000000..18d7328 --- /dev/null +++ b/.config/linux/system/module/common/tmux/Statusbar.nix @@ -0,0 +1,22 @@ +{ ... }: { + programs.tmux.extraConfig = '' + # Statusbar. + set -g status-interval 2 + set -g status-position bottom + set -g status-justify left + set -g status-style 'bg=color236 fg=color187' + + set -g status-left ' #[bold]#H-#S #(count=$(tmux list-clients -t #S | wc -l); [ $${count} -gt 1 ] && echo "($${count}) ")' + set -g status-left-length 50 + set -g status-right ' #(head -c -1 /sys/class/power_supply/BAT*/capacity 2> /dev/null && echo -n "% ")#[fg=color187,bg=color239] %Y-%m-%d #[bg=color138,fg=black,bold] %H:%M ' + set -g status-right-length 50 + + setw -g window-status-current-style 'fg=black bg=color143 bold' + setw -g window-status-current-format ' #[fg=black]#W#[fg=black]#F ' + + setw -g window-status-style 'fg=black bg=color138' + setw -g window-status-format ' #[fg=black]#W#[fg=black] ' + + setw -g window-status-bell-style 'fg=black bg=white bold' + ''; +} diff --git a/.config/linux/system/module/common/tmux/Window.nix b/.config/linux/system/module/common/tmux/Window.nix new file mode 100644 index 0000000..af19306 --- /dev/null +++ b/.config/linux/system/module/common/tmux/Window.nix @@ -0,0 +1,19 @@ +{ ... }: { + programs.tmux.extraConfig = '' + # Create new window. + bind -n M-Escape new-window -c "#{pane_current_path}" + bind -n M-t new-window -c "#{pane_current_path}" # NOTE: for compatibility reasons. + + # Close window. + bind -n M-x kill-window + bind -n M-X kill-window -a + + # Switch window. + bind -n M-e next-window + bind -n M-q previous-window + + # Move window. + bind -n M-E swap-window -t +1\; select-window -t +1 + bind -n M-Q swap-window -t -1\; select-window -t -1 + ''; +} diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf deleted file mode 100644 index 0ed0ac4..0000000 --- a/.config/tmux/tmux.conf +++ /dev/null @@ -1,95 +0,0 @@ -# Remap to . -unbind-key C-b -set-option -g prefix C-t -bind-key C-t send-prefix - -# Disable escape delay. -set -sg escape-time 0 - -# Remap split keys. -bind -n M-\\ split-window -h -c "#{pane_current_path}" -bind -n M-- split-window -v -c "#{pane_current_path}" -bind -n M-= select-layout tiled -bind -n M-W resize-pane -U 1 -bind -n M-S resize-pane -D 1 -bind -n M-A resize-pane -L 1 -bind -n M-D resize-pane -R 1 -unbind '"' -unbind % - -# Reload config. -bind -n M-r source-file ~/.config/tmux/tmux.conf - -# Swith panes with alt + hjkl. -bind -n M-a select-pane -L -bind -n M-d select-pane -R -bind -n M-w select-pane -U -bind -n M-s select-pane -D - -# Close pane. -bind -n M-c kill-pane -bind -n M-C kill-pane -a - -# Create new window. -bind -n M-Escape new-window -c "#{pane_current_path}" -bind -n M-t new-window -c "#{pane_current_path}" # NOTE: for compatibility with Termux as it does not support yet. - -# Close window. -bind -n M-x kill-window -bind -n M-X kill-window -a - -# Switch window. -bind -n M-e next-window -bind -n M-q previous-window - -# Move window. -bind -n M-E swap-window -t +1\; select-window -t +1 -bind -n M-Q swap-window -t -1\; select-window -t -1 - -# Detach. -bind -n M-z detach-client -bind -n M-Z detach-client -a - -# Scroll. -bind -n M-p copy-mode -u -bind -n M-n send-keys Pagedown - -# Copy mode. -setw -g mode-keys vi -bind -n M-v copy-mode -bind -n M-P choose-buffer -bind -T copy-mode-vi v send -X begin-selection -bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy" - -# Switch sessions. -bind -n M-9 switch-client -p -bind -n M-0 switch-client -n -bind -n M-g choose-session - -# Resize to smallest client. -set -g window-size smallest - -# Statusbar. -set -g status-interval 2 -set -g status-position bottom -set -g status-justify left -set -g status-style 'bg=color236 fg=color187' - -set -g status-left ' #[bold]#H-#S #(count=$(tmux list-clients -t #S | wc -l); [ ${count} -gt 1 ] && echo "(${count}) ")' -set -g status-left-length 50 -set -g status-right ' #(head -c -1 /sys/class/power_supply/BAT*/capacity 2> /dev/null && echo -n "% ")#[fg=color187,bg=color239] %Y-%m-%d #[bg=color138,fg=black,bold] %H:%M ' -set -g status-right-length 50 - -setw -g window-status-current-style 'fg=black bg=color143 bold' -setw -g window-status-current-format ' #[fg=black]#W#[fg=black]#F ' - -setw -g window-status-style 'fg=black bg=color138' -setw -g window-status-format ' #[fg=black]#W#[fg=black] ' - -setw -g window-status-bell-style 'fg=black bg=white bold' - -# Selection style. -set -g mode-style 'fg=black,bg=yellow bold' - -# Update environment from client. -set-option -g update-environment "SSH_CLIENT SSH_TTY DOCKER_CONFIG DOCKER_HOST DISPLAY XAUTHORITY" diff --git a/.gitignore b/.gitignore index 27f0326..41d32c0 100644 --- a/.gitignore +++ b/.gitignore @@ -66,10 +66,6 @@ !/.config/bash/ !/.config/bash/** -# Tmux config. -!/.config/tmux/ -!/.config/tmux/** - # Docker config. !/.config/docker/ !/.config/docker/** diff --git a/.local/share/flatpak/overrides/com.github.iwalton3.jellyfin-media-player b/.local/share/flatpak/overrides/com.github.iwalton3.jellyfin-media-player deleted file mode 100644 index cd9dd50..0000000 --- a/.local/share/flatpak/overrides/com.github.iwalton3.jellyfin-media-player +++ /dev/null @@ -1,2 +0,0 @@ -[Environment] -DRI_PRIME=1 diff --git a/.local/share/flatpak/overrides/com.usebottles.bottles b/.local/share/flatpak/overrides/com.usebottles.bottles deleted file mode 100644 index b77e1da..0000000 --- a/.local/share/flatpak/overrides/com.usebottles.bottles +++ /dev/null @@ -1,7 +0,0 @@ -[Context] -filesystems=/storage/cold_2/media/game/:ro;~/.config/MangoHud:ro;~/media/bottle;/storage/hot/media/bottle;~/download:ro;/storage/hot/media/save;~/media/save - -[Environment] -MANGOHUD=1 -MANGOHUD_CONFIGFILE=/home/voronind/.config/MangoHud/MangoHud.conf -DRI_PRIME=1 diff --git a/.local/share/flatpak/overrides/com.valvesoftware.Steam b/.local/share/flatpak/overrides/com.valvesoftware.Steam deleted file mode 100644 index cc253a1..0000000 --- a/.local/share/flatpak/overrides/com.valvesoftware.Steam +++ /dev/null @@ -1,9 +0,0 @@ -[Context] -devices=shm;kvm;dri -features=canbus -filesystems=!xdg-music;!xdg-pictures;!xdg-run/app/com.discordapp.Discord;/storage/hot/media/save;~/.config/MangoHud:ro;/storage/hot/media/steam;/storage/cold_2/media/steam - -[Environment] -MANGOHUD_CONFIGFILE=/home/voronind/.config/MangoHud/MangoHud.conf -MANGOHUD=1 -DRI_PRIME=1 diff --git a/.local/share/flatpak/overrides/global b/.local/share/flatpak/overrides/global deleted file mode 100644 index 2c84f57..0000000 --- a/.local/share/flatpak/overrides/global +++ /dev/null @@ -1,2 +0,0 @@ -[Context] -filesystems=xdg-config/gtk-3.0:ro;xdg-config/gtk-4.0:ro; diff --git a/.local/share/flatpak/overrides/io.mpv.Mpv b/.local/share/flatpak/overrides/io.mpv.Mpv deleted file mode 100644 index cd9dd50..0000000 --- a/.local/share/flatpak/overrides/io.mpv.Mpv +++ /dev/null @@ -1,2 +0,0 @@ -[Environment] -DRI_PRIME=1 diff --git a/.local/share/flatpak/overrides/org.blender.Blender b/.local/share/flatpak/overrides/org.blender.Blender deleted file mode 100644 index 5f7f5e1..0000000 --- a/.local/share/flatpak/overrides/org.blender.Blender +++ /dev/null @@ -1,6 +0,0 @@ -[Context] -devices=all;shm;kvm -filesystems=home;host-etc;host-os - -[Environment] -DRI_PRIME=1 diff --git a/.local/share/flatpak/overrides/org.kde.kdenlive b/.local/share/flatpak/overrides/org.kde.kdenlive deleted file mode 100644 index cd9dd50..0000000 --- a/.local/share/flatpak/overrides/org.kde.kdenlive +++ /dev/null @@ -1,2 +0,0 @@ -[Environment] -DRI_PRIME=1 diff --git a/.local/share/flatpak/overrides/org.mozilla.Thunderbird b/.local/share/flatpak/overrides/org.mozilla.Thunderbird deleted file mode 100644 index 14656c3..0000000 --- a/.local/share/flatpak/overrides/org.mozilla.Thunderbird +++ /dev/null @@ -1,2 +0,0 @@ -[Context] -filesystems=~/.thunderbird diff --git a/.local/share/flatpak/overrides/org.mozilla.firefox b/.local/share/flatpak/overrides/org.mozilla.firefox deleted file mode 100644 index c9dfcca..0000000 --- a/.local/share/flatpak/overrides/org.mozilla.firefox +++ /dev/null @@ -1,3 +0,0 @@ -[Context] -devices=dri -filesystems=!xdg-download;~/.config/firefox:ro;~/download;~/.mozilla