mirror of
https://github.com/Gerg-L/nixos.git
synced 2025-12-10 00:43:56 -05:00
refactor: move zellij to shared module
This commit is contained in:
parent
362b9dda0f
commit
5b9d021b59
3 changed files with 39 additions and 18 deletions
39
nixosModules/zellij/default.nix
Normal file
39
nixosModules/zellij/default.nix
Normal file
|
|
@ -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
|
||||
'';
|
||||
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue