From e6c53843b4d334fdd5820d17880d1243456790bd Mon Sep 17 00:00:00 2001 From: Glen Goodwin Date: Mon, 19 Jun 2023 02:58:07 -0400 Subject: [PATCH] feat: Dump of updates --- devenv.nix | 3 - flake.lock | 54 ++++----- hosts/configuration.nix | 2 + hosts/home.nix | 14 ++- modules/desktop/virtualisation/docker.nix | 1 + modules/editors/nvim/home.nix | 2 +- modules/programs/waybar.nix | 3 +- modules/shell/git/home.nix | 9 ++ modules/shell/tmux/home.nix | 141 ++++++++++++++++++++++ modules/shell/tmux/ta.sh | 77 ++++++++++++ modules/shell/zsh.nix | 2 +- modules/shell/zsh/home.nix | 1 + 12 files changed, 274 insertions(+), 35 deletions(-) create mode 100644 modules/shell/tmux/home.nix create mode 100644 modules/shell/tmux/ta.sh diff --git a/devenv.nix b/devenv.nix index 99d91cd..0bb05e8 100644 --- a/devenv.nix +++ b/devenv.nix @@ -1,9 +1,6 @@ { pkgs, ... }: { - # https://devenv.sh/basics/ - env.GREET = "devenv"; - # https://devenv.sh/packages/ packages = [ pkgs.git ]; diff --git a/flake.lock b/flake.lock index ed2347b..f9fa8e0 100644 --- a/flake.lock +++ b/flake.lock @@ -10,11 +10,11 @@ "pre-commit-hooks": "pre-commit-hooks" }, "locked": { - "lastModified": 1686054274, - "narHash": "sha256-93aebyN7EMmeFFXisFIvp28UEbrozu79vd3pKPjvNR0=", + "lastModified": 1686642933, + "narHash": "sha256-5Z4uitx27QtZIrG9sOSJlZRNcVQn/TI36nj7o70n5Dw=", "owner": "cachix", "repo": "devenv", - "rev": "c51a56bac8853c019241fe8d821c0a0d82422835", + "rev": "f5278b5d56e39f86a299a2e1889906933a26f762", "type": "github" }, "original": { @@ -84,11 +84,11 @@ ] }, "locked": { - "lastModified": 1685395684, - "narHash": "sha256-XUUWE5XJiGZ2Wi+Mxv/mIwKYDPEC8gYHkHyT3+/sciY=", + "lastModified": 1686666715, + "narHash": "sha256-lBYoA/AI22znVdwuRd1yFwixeAT9m0oudP4TVdhJiC0=", "owner": "nix-community", "repo": "home-manager", - "rev": "43ed7048f670661d1ae2ea0d2f7655e87e7b0461", + "rev": "e4aa9fd83b5c2d43b3c9c9de979a8675fcb8e563", "type": "github" }, "original": { @@ -107,11 +107,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1685380658, - "narHash": "sha256-LPih0Q//p8IurXG9kGRVGAqV4AUKVYj9xkk3sYYAj6I=", + "lastModified": 1686680001, + "narHash": "sha256-JPcudWZ2bBwkJofGTV23NyXw/wo7PyiLFIdqPfrzxHE=", "owner": "vaxerski", "repo": "Hyprland", - "rev": "51a930f802c71a0e67f05e7b176ded74e8e95f87", + "rev": "7762ac0173b860af83e58d56409f9cf0fa7252e9", "type": "github" }, "original": { @@ -128,11 +128,11 @@ ] }, "locked": { - "lastModified": 1681065697, - "narHash": "sha256-QPzwwlGKX95tl6ZEshboZbEwwAXww6lNLdVYd6T9Mrc=", + "lastModified": 1684265364, + "narHash": "sha256-AxNnWbthsuNx73HDQr0eBxrcE3+yfl/WsaXZqUFmkpQ=", "owner": "hyprwm", "repo": "hyprland-protocols", - "rev": "4d29e48433270a2af06b8bc711ca1fe5109746cd", + "rev": "8c279b9fb0f2b031427dc5ef4eab53f2ed835530", "type": "github" }, "original": { @@ -183,11 +183,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1685290091, - "narHash": "sha256-GGQYNZ7POoqPTtXgPOLUuSiHkOKFRWYpCoWUOSeSRoU=", + "lastModified": 1686501370, + "narHash": "sha256-G0WuM9fqTPRc2URKP9Lgi5nhZMqsfHGrdEbrLvAPJcg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "4e37b4e55b60fb7d43d2b62deb51032a489bcbe8", + "rev": "75a5ebf473cd60148ba9aec0d219f72e5cf52519", "type": "github" }, "original": { @@ -231,11 +231,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1685347552, - "narHash": "sha256-9woSppRyUFo26yUffORTzttJ+apOt8MmCv6RxpPNTU4=", + "lastModified": 1686582075, + "narHash": "sha256-vtflsfKkHtF8IduxDNtbme4cojiqvlvjp5QNYhvoHXc=", "owner": "nixos", "repo": "nixpkgs", - "rev": "f2f1ec390714d303cf84ba086e34e45b450dd8c4", + "rev": "7e63eed145566cca98158613f3700515b4009ce3", "type": "github" }, "original": { @@ -260,11 +260,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1682596858, - "narHash": "sha256-Hf9XVpqaGqe/4oDGr30W8HlsWvJXtMsEPHDqHZA6dDg=", + "lastModified": 1686050334, + "narHash": "sha256-R0mczWjDzBpIvM3XXhO908X5e2CQqjyh/gFbwZk/7/Q=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "fb58866e20af98779017134319b5663b8215d912", + "rev": "6881eb2ae5d8a3516e34714e7a90d9d95914c4dc", "type": "github" }, "original": { @@ -286,11 +286,11 @@ "flake": false, "locked": { "host": "gitlab.freedesktop.org", - "lastModified": 1682436395, - "narHash": "sha256-GGEjkQO9m7YLYIXIXM76HWdhjg4Ye+oafOtyaFAYKI4=", + "lastModified": 1686573751, + "narHash": "sha256-5vnFxEMvn4wzT+XKR5Jo8VSn1hXrdf/mWuTmdHhRFBs=", "owner": "wlroots", "repo": "wlroots", - "rev": "6830bfc17fd94709e2cdd4da0af989f102a26e59", + "rev": "6e8fb5509f2c94d09d4efa0f9b1f40b37bf73863", "type": "gitlab" }, "original": { @@ -312,11 +312,11 @@ ] }, "locked": { - "lastModified": 1682439384, - "narHash": "sha256-zHDa8LCZs05TZHQSIZ3ucwyMPglBGHcqTBzfkLjYXTM=", + "lastModified": 1685385764, + "narHash": "sha256-r+XMyOoRXq+hlfjayb+fyi9kq2JK48TrwuNIAXqlj7U=", "owner": "hyprwm", "repo": "xdg-desktop-portal-hyprland", - "rev": "c0e233955568fbea4e859336f6d3d14d51294d7c", + "rev": "4d9ff0c17716936e0b5ca577a39e263633901ed1", "type": "github" }, "original": { diff --git a/hosts/configuration.nix b/hosts/configuration.nix index f703016..c5f61ac 100644 --- a/hosts/configuration.nix +++ b/hosts/configuration.nix @@ -71,6 +71,7 @@ pciutils usbutils wget + lsof ]; }; @@ -95,6 +96,7 @@ }; pulse.enable = true; jack.enable = true; + wireplumber.enable = true; }; # Open ports in the firewall. diff --git a/hosts/home.nix b/hosts/home.nix index 2b2396b..4a33ba6 100644 --- a/hosts/home.nix +++ b/hosts/home.nix @@ -6,6 +6,7 @@ [ (import ../modules/programs/wofi.nix) ] ++ [ (import ../modules/editors/nvim/home.nix) ] ++ [ (import ../modules/programs/devenv/home.nix) ] ++ + [ (import ../modules/shell/tmux/home.nix) ] ++ [ (import ../modules/shell/zsh/home.nix) ]; home = { @@ -15,7 +16,7 @@ packages = with pkgs; [ # Terminal - btop # Resource Manager + htop nitch # Minimal fetch tldr # Helper zellij # multiplexer @@ -38,6 +39,17 @@ dbeaver ansible nixpkgs-fmt + zoxide + webcord + nfs-utils + keychain + slides + glow + entr + just + bandwhich + navi + git-crypt diff --git a/modules/desktop/virtualisation/docker.nix b/modules/desktop/virtualisation/docker.nix index 3256e19..81cb343 100644 --- a/modules/desktop/virtualisation/docker.nix +++ b/modules/desktop/virtualisation/docker.nix @@ -16,6 +16,7 @@ environment.systemPackages = with pkgs; [ docker-compose distrobox + kind ]; } diff --git a/modules/editors/nvim/home.nix b/modules/editors/nvim/home.nix index e84db91..7c1f643 100644 --- a/modules/editors/nvim/home.nix +++ b/modules/editors/nvim/home.nix @@ -26,7 +26,7 @@ nvim-lspconfig nvim-tree-lua nvim-ts-rainbow - (nvim-treesitter.withPlugins (_: pkgs.tree-sitter.allGrammars)) + nvim-treesitter.withAllGrammars plenary-nvim telescope-fzy-native-nvim telescope-nvim diff --git a/modules/programs/waybar.nix b/modules/programs/waybar.nix index 61cb25c..2d915fb 100644 --- a/modules/programs/waybar.nix +++ b/modules/programs/waybar.nix @@ -26,8 +26,7 @@ background-color: rgba(80,100,100,0.4); } window#waybar { - background-color: rgba(0,0,0,0.5); - background: transparent; + background-color: rgba(0,0,0,0.8); transition-property: background-color; transition-duration: .5s; border-bottom: none; diff --git a/modules/shell/git/home.nix b/modules/shell/git/home.nix index 32eea76..f099fc6 100644 --- a/modules/shell/git/home.nix +++ b/modules/shell/git/home.nix @@ -11,6 +11,15 @@ }; }; + programs.zsh = { + shellAliases = { + + trackme = "git branch --set-upstream-to=origin/$(git symbolic-ref --short HEAD)"; + rebasemain = "git pull origin main --rebase"; + + }; + }; + home.packages = with pkgs; [ cocogitto lazygit diff --git a/modules/shell/tmux/home.nix b/modules/shell/tmux/home.nix new file mode 100644 index 0000000..502adf8 --- /dev/null +++ b/modules/shell/tmux/home.nix @@ -0,0 +1,141 @@ +{ pkgs, config, ... }: +{ + programs.tmux = { + enable = true; + clock24 = true; + plugins = with pkgs.tmuxPlugins; [ + sensible + yank + { + plugin = power-theme; + extraConfig = '' + set -g @tmux_power_theme 'sky' + ''; + } + resurrect + continuum + ]; + + extraConfig = '' + bind -n M-r source-file ~/.config/tmux/tmux.conf + + set -g mouse on + + set-option -g status-position top + + bind-key g display-popup -h 95% -w 95% -E 'lazygit' + bind-key t display-popup -h 95% -w 95% -E "${pkgs.htop}/bin/htop" + + bind C-g display-popup -E "tat ~/gallery" + + bind -n M-g display-popup -E "tmux new-session -A -s scratch" + + bind -n M-b switch-client -l + bind -n M-p previous-window + bind -n M-n next-window + bind -n M-P switch-client -p + bind -n M-N switch-client -n + + unbind f + bind f resize-pane -Z + + # create session + bind C-c new-session + + # split current window horizontally + bind - split-window -v + # split current window vertically + bind _ split-window -h + + # Select Layouts + #――――――――――――――――― + bind -n M-a select-layout main-vertical + bind -n M-A select-layout main-horizontal + bind -n M-E select-layout even-vertical + bind -n M-V select-layout even-horizontal + + # pane navigation + bind -r h select-pane -L # move left + bind -r j select-pane -D # move down + bind -r k select-pane -U # move up + bind -r l select-pane -R # move right + bind > swap-pane -D # swap current pane with the next one + bind < swap-pane -U # swap current pane with the previous one + + # pane resizing + bind -r H resize-pane -L 2 + bind -r J resize-pane -D 2 + bind -r K resize-pane -U 2 + bind -r L resize-pane -R 2 + bind -r c-f resize-pane -Z + + # window navigation + unbind n + unbind p + + setw -g mode-keys vi + + bind Enter copy-mode # enter copy mode + + bind -T copy-mode-vi v send -X begin-selection + bind -T copy-mode-vi C-v send -X rectangle-toggle + bind -T copy-mode-vi y send -X copy-selection-and-cancel + bind -T copy-mode-vi Escape send -X cancel + bind -T copy-mode-vi H send -X start-of-line + bind -T copy-mode-vi L send -X end-of-line + + # -- buffers ------------------------------------------------------------------- + + bind b list-buffers # list paste buffers + bind p paste-buffer -p # paste from the top paste buffer + bind P choose-buffer # choose which buffer to paste from + + # -- display ------------------------------------------------------------------- + + set -g base-index 1 # start windows numbering at 1 + setw -g pane-base-index 1 # make pane numbering consistent with windows + set -g renumber-windows on # renumber windows when a window is closed + + bind k display-popup -E "\ + tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\ + fzf --reverse -m --header=kill-session |\ + xargs -I {} tmux kill-session -t {}" + + bind C-j display-popup -E "\ + tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\ + sed '/^$/d' |\ + fzf --reverse --header jump-to-session --preview 'tmux capture-pane -pt {}' |\ + xargs tmux switch-client -t" + + ''; + }; + programs.tmate = { + enable = true; + }; + + home.packages = [ + # Open tmux for current project. + (pkgs.writeShellApplication { + name = "tat"; + runtimeInputs = [ pkgs.tmux pkgs.fzf ]; + text = builtins.readFile ./ta.sh; + }) + pkgs.fzf + ]; + + + programs.zsh = { + shellAliases = { + tx = "tmux new -s default"; + ta = "tmux attach -t"; + tad = "tmux attach -d -t"; + ts = "tmux new-session -s"; + tl = "tmux list-sessions"; + tksv = "tmux kill-server"; + tkss = "tmux kill-session -t"; + + }; + }; +} + + diff --git a/modules/shell/tmux/ta.sh b/modules/shell/tmux/ta.sh new file mode 100644 index 0000000..be17bd3 --- /dev/null +++ b/modules/shell/tmux/ta.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +not_in_tmux() { + [ -z "$TMUX" ] +} + +DIR="$1" + +# If no arguments are passed in, try to immediately attach or start without further input +echo "$DIR" +if [ -z "$DIR" ]; then + if not_in_tmux; then + tmux attach && exit 1 || DIR="--start" + else + exit 1 + fi +fi + +# If --start was passed in, immediately start a new session based on the current directory +if [ "$DIR" = "--start" ]; then + echo "Starting" + path_name="$(basename "$PWD" | tr . -)" + session_name="${path_name//./_}" +else + # Ask the user which directory to start in + _session_name=$(cd "$DIR" && find -L . -maxdepth 1 -type d -printf "%f\n" | sed "s|/||g" | fzf --reverse --header="Select project from $(basename "$DIR") >") + session_name="${_session_name//./_}" + path_name="$DIR/$_session_name" +fi + +echo "Session name is \"$session_name\"" +echo "Path name is \"$path_name\"" + +if [ -z "$session_name" ]; then + # Operation cancelled by user + exit 1 +fi + +session_exists() { + # Check if the $session_name exists + tmux has-session -t "=$session_name" +} + +create_detached_session() { + if [ "$DIR" = "--start" ]; then + (TMUX='' + tmux new-session -Ad -s "$session_name" -c "$path_name" + ) + else + (TMUX='' + tmux new-session -Ad -s "$session_name" -c "$path_name" + tmux split-window -vb -t "$session_name" -c "$path_name" -p 70 + tmux send-keys -t "$session_name" "nvim '+Telescope find_files'" Enter + ) + fi +} + +create_if_needed_and_attach() { + if not_in_tmux; then + tmux new-session -As "$session_name" -c "$path_name" + else + if ! session_exists; then + create_detached_session + fi + tmux switch-client -t "$session_name" + fi +} + +attach_to_first_session() { + first_session_name=$(tmux list-sessions -F "#{session_name}" | head -n 1) + if [ -n "$first_session_name" ]; then + tmux attach -t "$first_session_name" + tmux choose-tree -Za + fi +} + +create_if_needed_and_attach || attach_to_first_session diff --git a/modules/shell/zsh.nix b/modules/shell/zsh.nix index 6439ed0..66a62d7 100644 --- a/modules/shell/zsh.nix +++ b/modules/shell/zsh.nix @@ -22,7 +22,7 @@ # Hook direnv #emulate zsh -c "$(direnv hook zsh)" # Swag - ${pkgs.nitch}/bin/nitch + #${pkgs.nitch}/bin/nitch #eval "$(direnv hook zsh)" eval "$(atuin init zsh)" diff --git a/modules/shell/zsh/home.nix b/modules/shell/zsh/home.nix index ca52dd3..e0bbf1a 100644 --- a/modules/shell/zsh/home.nix +++ b/modules/shell/zsh/home.nix @@ -4,6 +4,7 @@ enable = true; shellAliases = { update = "sudo nixos-rebuild switch"; + clean = "nix-collect-garbage -d"; reload = "source ~/.zshrc"; "." = "cd ../";