From 5b9d021b59a5dca0c9e9a7afa397fca606d9dcae Mon Sep 17 00:00:00 2001 From: Gerg-L Date: Sat, 24 May 2025 23:44:44 -0400 Subject: [PATCH 1/4] refactor: move zellij to shared module --- nixosConfigurations/gerg-desktop/main.nix | 18 --------- nixosModules/zellij/default.nix | 39 +++++++++++++++++++ .../zellij}/monitor.ps | 0 3 files changed, 39 insertions(+), 18 deletions(-) create mode 100644 nixosModules/zellij/default.nix rename {nixosConfigurations/gerg-desktop => nixosModules/zellij}/monitor.ps (100%) diff --git a/nixosConfigurations/gerg-desktop/main.nix b/nixosConfigurations/gerg-desktop/main.nix index 960d59b..2935475 100644 --- a/nixosConfigurations/gerg-desktop/main.nix +++ b/nixosConfigurations/gerg-desktop/main.nix @@ -41,7 +41,6 @@ vesktop gh nixfmt-rfc-style - zellij tidal-hifi hyperfine @@ -135,23 +134,6 @@ zsh = { shellAliases.cd = "z"; - interactiveShellInit = - let - monitorScript = pkgs.replaceVarsWith { - src = ./monitor.ps; - replacements = builtins.mapAttrs (_: lib.getExe) { - inherit (pkgs) perl xdotool; - }; - isExecutable = true; - }; - in - '' - if [[ -z "$ZELLIJ" ]]; then - MONITOR="$(${monitorScript} || true)" - zellij attach -c "''${MONITOR:+"$MONITOR@"}$USER" - exit - fi - ''; }; nix-index = { diff --git a/nixosModules/zellij/default.nix b/nixosModules/zellij/default.nix new file mode 100644 index 0000000..b023b38 --- /dev/null +++ b/nixosModules/zellij/default.nix @@ -0,0 +1,39 @@ +{ + lib, + pkgs, + config, +}: +{ + options.local.zellij = lib.mkEnableOption "zellij" // { + default = true; + }; + + config = lib.mkIf config.local.zellij { + local.packages = { + inherit (pkgs) zellij; + }; + + programs.zsh.interactiveShellInit = + let + monitorScript = pkgs.replaceVarsWith { + src = ./monitor.ps; + replacements = builtins.mapAttrs (_: lib.getExe) { + inherit (pkgs) perl xdotool; + }; + isExecutable = true; + }; + in + '' + if [[ -z "$ZELLIJ" ]]; then + if [[ -n "$SSH_TTY" ]]; then + zellij attach -c "SSH@$USER" + else + MONITOR="$(${monitorScript} || true)" + zellij attach -c "''${MONITOR:+"$MONITOR@"}$USER" + fi + exit + fi + ''; + + }; +} diff --git a/nixosConfigurations/gerg-desktop/monitor.ps b/nixosModules/zellij/monitor.ps similarity index 100% rename from nixosConfigurations/gerg-desktop/monitor.ps rename to nixosModules/zellij/monitor.ps From 7fd110798b40b2103e5ba866ccf374697e1de189 Mon Sep 17 00:00:00 2001 From: Gerg-L Date: Sat, 24 May 2025 23:45:03 -0400 Subject: [PATCH 2/4] refactor: move zoxide to shared module --- nixosConfigurations/gerg-desktop/main.nix | 6 ------ nixosModules/shell.nix | 2 ++ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/nixosConfigurations/gerg-desktop/main.nix b/nixosConfigurations/gerg-desktop/main.nix index 2935475..fda29c5 100644 --- a/nixosConfigurations/gerg-desktop/main.nix +++ b/nixosConfigurations/gerg-desktop/main.nix @@ -130,12 +130,6 @@ silent = true; }; - zoxide.enable = true; - - zsh = { - shellAliases.cd = "z"; - }; - nix-index = { enable = true; package = nix-index-database.packages.nix-index-with-db; diff --git a/nixosModules/shell.nix b/nixosModules/shell.nix index 009d25e..318c0d7 100644 --- a/nixosModules/shell.nix +++ b/nixosModules/shell.nix @@ -32,10 +32,12 @@ lx = "eza -lbhHigUmuSa@ --time-style=long-iso --git --color-scale"; lS = "eza -1"; lt = "eza --tree --level=2"; + cd = "z"; }; interactiveShellInit = "fetch-rs"; }; + programs.zoxide.enable = true; programs.starship = { enable = true; settings = { From 0c92a53bb5b93feefb8d249906d8f1a79093258d Mon Sep 17 00:00:00 2001 From: Gerg-L Date: Mon, 26 May 2025 00:43:37 -0400 Subject: [PATCH 3/4] chore: update --- flake.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/flake.lock b/flake.lock index 4e82c5c..5080c1b 100644 --- a/flake.lock +++ b/flake.lock @@ -387,11 +387,11 @@ }, "mnw": { "locked": { - "lastModified": 1747615842, - "narHash": "sha256-pAh9ndf+GdoCfsWaNATFDjgiax9fOYdWzguYV1H/W0E=", + "lastModified": 1748203683, + "narHash": "sha256-zd5GFPg/lVbIILs0ze0bLUsFS72TD/N0Vq5IEGmSG7Y=", "owner": "gerg-l", "repo": "mnw", - "rev": "b62120999410eb4a4e27359a3e1c0a22fcc0baff", + "rev": "0cb0df3a6f26cbb42f3e096ec65bc7263aab9757", "type": "github" }, "original": { @@ -411,11 +411,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1748070814, - "narHash": "sha256-UENoloiY25w0GmPsni8aswhks13qD1sT7XPQgmBd4tU=", + "lastModified": 1748176456, + "narHash": "sha256-9KctKybf6ypTTeqepgWPwCLU2V2tVrLXL8OtHzfKEhY=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "1654f815b79267a32c0eb9feb5962089d855d287", + "rev": "f788fa289c6e2769339eb519ce7e3732f24a8096", "type": "github" }, "original": { @@ -427,11 +427,11 @@ "neovim-src": { "flake": false, "locked": { - "lastModified": 1748041342, - "narHash": "sha256-gYkZbws7QEZ6o5Kh8IPotFAk1thbzzm3C8+vs/M32E4=", + "lastModified": 1748117132, + "narHash": "sha256-RscRZfMlnsCYzLbgskVPc0AOqtcdyg77htxaVT0xFpc=", "owner": "neovim", "repo": "neovim", - "rev": "9784bc134624ff6dcf2e59e3c3998e206d2adad7", + "rev": "06043af27d9c9258eeebf16e4691dcb92f9b857d", "type": "github" }, "original": { @@ -631,11 +631,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1748138789, - "narHash": "sha256-FWrmnGlRlQy1MYkGzhzQ2eaW+unNU0Te+ns14ajtQ5E=", + "lastModified": 1748217776, + "narHash": "sha256-H5yi/nBlTL8TZ3GKvjJhJReEMc3z1xLBocVvewaJ5SY=", "owner": "Gerg-L", "repo": "nvim-flake", - "rev": "3071f5d63c727a218e459ad10f2cc01404425636", + "rev": "19ee0aebca7d0d675539efde545dc49cee7e3d20", "type": "github" }, "original": { From 23400b0ab35cc0c6a030d66f4287375142c250a9 Mon Sep 17 00:00:00 2001 From: Gerg-L Date: Mon, 26 May 2025 00:44:36 -0400 Subject: [PATCH 4/4] refactor: don't close zsh when exiting zellij --- nixosModules/zellij/default.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/nixosModules/zellij/default.nix b/nixosModules/zellij/default.nix index b023b38..8c10624 100644 --- a/nixosModules/zellij/default.nix +++ b/nixosModules/zellij/default.nix @@ -31,7 +31,6 @@ MONITOR="$(${monitorScript} || true)" zellij attach -c "''${MONITOR:+"$MONITOR@"}$USER" fi - exit fi '';