From eb516819fad0aab9c40bdc9f711437ee6fe4469d Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 24 Jul 2025 23:16:16 +0100 Subject: [PATCH] Move tmux-sessionizer configuration --- home-manager/opdavies/PW05CH3L.nix | 13 +---- home-manager/opdavies/t480.nix | 12 ----- modules/home-manager/default.nix | 1 - modules/home-manager/tmux-sessionizer.nix | 64 ----------------------- modules2/hosts/t480/tmux-sessionizer.nix | 15 ++++++ modules2/tmux-sessionizer/config.nix | 26 +++++++++ modules2/tmux-sessionizer/default.nix | 30 +++++++++++ modules2/tmux-sessionizer/package.nix | 7 +++ 8 files changed, 79 insertions(+), 89 deletions(-) delete mode 100644 modules/home-manager/tmux-sessionizer.nix create mode 100644 modules2/hosts/t480/tmux-sessionizer.nix create mode 100644 modules2/tmux-sessionizer/config.nix create mode 100644 modules2/tmux-sessionizer/default.nix create mode 100644 modules2/tmux-sessionizer/package.nix diff --git a/home-manager/opdavies/PW05CH3L.nix b/home-manager/opdavies/PW05CH3L.nix index fd76689d..f25a0dd6 100644 --- a/home-manager/opdavies/PW05CH3L.nix +++ b/home-manager/opdavies/PW05CH3L.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ pkgs, ... }: { imports = [ ../common ]; @@ -13,17 +13,6 @@ notes.enable = true; ranger.enable = true; starship.enable = true; - - tmux-sessionizer.enable = true; - tmux-sessionizer.searchPaths = - let - inherit (config.xdg) userDirs; - in - [ - "${userDirs.extraConfig.XDG_REPOS_DIR}:2" - "${userDirs.documents}:1" - ]; - zsh.enable = true; }; diff --git a/home-manager/opdavies/t480.nix b/home-manager/opdavies/t480.nix index b822897a..338ae72f 100644 --- a/home-manager/opdavies/t480.nix +++ b/home-manager/opdavies/t480.nix @@ -21,18 +21,6 @@ ranger.enable = true; sxhkd.enable = true; starship.enable = true; - - tmux-sessionizer.enable = true; - tmux-sessionizer.searchPaths = - let - inherit (config.xdg) userDirs; - in - [ - "${userDirs.extraConfig.XDG_REPOS_DIR}:2" - "${userDirs.documents}:1" - "${config.home.homeDirectory}/tmp" - ]; - zsh.enable = true; }; diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 2a9f1366..50cd8d69 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -23,7 +23,6 @@ ./screenkey.nix ./starship.nix ./sxhkd.nix - ./tmux-sessionizer.nix ./zsh ]; } diff --git a/modules/home-manager/tmux-sessionizer.nix b/modules/home-manager/tmux-sessionizer.nix deleted file mode 100644 index 242c0e08..00000000 --- a/modules/home-manager/tmux-sessionizer.nix +++ /dev/null @@ -1,64 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: - -with lib; - -let - cfg = config.features.cli.tmux-sessionizer; -in -{ - options.features.cli.tmux-sessionizer = { - enable = mkEnableOption "Enable tmux-sessionizer"; - enableDmenuIntegration = mkEnableOption "Enable dmenu integration"; - - searchPaths = mkOption { - default = [ config.home.homeDirectory ]; - type = types.listOf types.str; - description = "List of search paths for tmux-sessionizer to use."; - }; - - # TODO: add TS_EXTRA_SEARCH_PATHS. - # TODO: add TS_MAX_DEPTH. - # TODO: add TS_SESSION_COMMANDS once I figure out what they're for. - }; - - config = mkIf cfg.enable { - home.packages = with pkgs; [ - tmux-sessionizer - ]; - - home.file.".tmux-sessionizer".source = "${ - pkgs.writeShellApplication { - name = ".tmux-sessionizer"; - - runtimeInputs = with pkgs; [ - tmux - ]; - - text = '' - set +o errexit - set +o nounset - - if [[ "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/os" || "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/personal" || "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/work" ]]; then - clear - - return - fi - - tmux new-window -d -n scratch - nvim . - clear - ''; - } - }/bin/.tmux-sessionizer"; - - xdg.configFile."tmux-sessionizer/tmux-sessionizer.conf".text = '' - TS_SEARCH_PATHS=(${builtins.concatStringsSep " " cfg.searchPaths}) - TS_SESSION_COMMANDS=(nvim .) - ''; - }; -} diff --git a/modules2/hosts/t480/tmux-sessionizer.nix b/modules2/hosts/t480/tmux-sessionizer.nix new file mode 100644 index 00000000..6439aa65 --- /dev/null +++ b/modules2/hosts/t480/tmux-sessionizer.nix @@ -0,0 +1,15 @@ +{ + flake.modules.homeManager.base = + { config, ... }: + { + programs.tmux-sessionizer.searchPaths = + let + inherit (config.xdg) userDirs; + in + [ + "${userDirs.extraConfig.XDG_REPOS_DIR}:2" + "${userDirs.documents}:1" + "${config.home.homeDirectory}/tmp" + ]; + }; +} diff --git a/modules2/tmux-sessionizer/config.nix b/modules2/tmux-sessionizer/config.nix new file mode 100644 index 00000000..83b29d59 --- /dev/null +++ b/modules2/tmux-sessionizer/config.nix @@ -0,0 +1,26 @@ +{ lib, ... }: + +{ + flake.modules.homeManager.base = + { config, ... }: + { + options.programs.tmux-sessionizer = { + searchPaths = lib.mkOption { + default = [ config.home.homeDirectory ]; + type = lib.types.listOf lib.types.str; + description = "List of search paths for tmux-sessionizer to use."; + }; + + # TODO: add TS_EXTRA_SEARCH_PATHS. + # TODO: add TS_MAX_DEPTH. + # TODO: add TS_SESSION_COMMANDS once I figure out what they're for. + }; + + config = { + xdg.configFile."tmux-sessionizer/tmux-sessionizer.conf".text = '' + TS_SEARCH_PATHS=(${builtins.concatStringsSep " " config.programs.tmux-sessionizer.searchPaths}) + TS_SESSION_COMMANDS=(nvim .) + ''; + }; + }; +} diff --git a/modules2/tmux-sessionizer/default.nix b/modules2/tmux-sessionizer/default.nix new file mode 100644 index 00000000..8f4513b5 --- /dev/null +++ b/modules2/tmux-sessionizer/default.nix @@ -0,0 +1,30 @@ +{ + flake.modules.homeManager.base = + { config, pkgs, ... }: + { + home.file.".tmux-sessionizer".source = "${ + pkgs.writeShellApplication { + name = ".tmux-sessionizer"; + + runtimeInputs = with pkgs; [ + tmux + ]; + + text = '' + set +o errexit + set +o nounset + + if [[ "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/os" || "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/personal" || "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/work" ]]; then + clear + + return + fi + + tmux new-window -d -n scratch + nvim . + clear + ''; + } + }/bin/.tmux-sessionizer"; + }; +} diff --git a/modules2/tmux-sessionizer/package.nix b/modules2/tmux-sessionizer/package.nix new file mode 100644 index 00000000..d87d15d7 --- /dev/null +++ b/modules2/tmux-sessionizer/package.nix @@ -0,0 +1,7 @@ +{ + flake.modules.homeManager.base = + { pkgs, ... }: + { + home.packages = with pkgs; [ tmux-sessionizer ]; + }; +}