From dc2de9334d2d619322098e6a5e52084fccb36349 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 23 Apr 2025 14:19:05 +0100 Subject: [PATCH] Make directories configurable using a patch --- home/opdavies/PW05CH3L.nix | 21 +++++++- home/opdavies/t480.nix | 21 +++++++- modules/home-manager/cli/tmux-sessionizer.nix | 52 ++++++++++++------- .../configure-directories.patch | 15 ------ pkgs/tmux-sessionizer/default.nix | 6 ++- 5 files changed, 77 insertions(+), 38 deletions(-) delete mode 100644 pkgs/tmux-sessionizer/configure-directories.patch diff --git a/home/opdavies/PW05CH3L.nix b/home/opdavies/PW05CH3L.nix index 215f4d10..c4d568b0 100644 --- a/home/opdavies/PW05CH3L.nix +++ b/home/opdavies/PW05CH3L.nix @@ -1,3 +1,5 @@ +{ config, options, ... }: + { imports = [ ../common ]; @@ -16,7 +18,24 @@ ranger.enable = true; starship.enable = true; tmux.enable = true; - tmux-sessionizer.enable = true; + + tmux-sessionizer = { + enable = true; + + directories = + let + inherit (config.xdg.userDirs) documents extraConfig; + + repos = extraConfig.XDG_REPOS_DIR; + in + options.homeManagerModules.cli.tmux-sessionizer.directories.default + ++ [ + repos + "${repos}/*" + documents + ]; + }; + zsh.enable = true; }; diff --git a/home/opdavies/t480.nix b/home/opdavies/t480.nix index e8549598..0b621579 100644 --- a/home/opdavies/t480.nix +++ b/home/opdavies/t480.nix @@ -1,3 +1,5 @@ +{ config, options, ... }: + { imports = [ ../common ]; @@ -18,7 +20,24 @@ ranger.enable = true; starship.enable = true; tmux.enable = true; - tmux-sessionizer.enable = true; + + tmux-sessionizer = { + enable = true; + + directories = + let + inherit (config.xdg.userDirs) documents extraConfig; + + repos = extraConfig.XDG_REPOS_DIR; + in + options.homeManagerModules.cli.tmux-sessionizer.directories.default + ++ [ + repos + "${repos}/*" + documents + ]; + }; + zsh.enable = true; }; diff --git a/modules/home-manager/cli/tmux-sessionizer.nix b/modules/home-manager/cli/tmux-sessionizer.nix index d94063c9..25748f45 100644 --- a/modules/home-manager/cli/tmux-sessionizer.nix +++ b/modules/home-manager/cli/tmux-sessionizer.nix @@ -11,36 +11,48 @@ let cfg = config.homeManagerModules.cli.tmux-sessionizer; in { - options.homeManagerModules.cli.tmux-sessionizer.enable = mkEnableOption "Enable tmux-sessionizer"; + options.homeManagerModules.cli.tmux-sessionizer = { + enable = mkEnableOption "Enable tmux-sessionizer"; + + directories = mkOption { + default = [ config.home.homeDirectory ]; + type = types.listOf types.str; + description = "List of directories for tmux-sessionizer to use."; + }; + }; config = mkIf cfg.enable { home.packages = with pkgs; [ tmux-sessionizer ]; - xdg.configFile."tmux-sessionizer/default".source = "${ - pkgs.writeShellApplication { - name = ".tmux-sessionizer"; + xdg.configFile = { + "tmux-sessionizer/default".source = "${ + pkgs.writeShellApplication { + name = ".tmux-sessionizer"; - runtimeInputs = with pkgs; [ - tmux - ]; + runtimeInputs = with pkgs; [ + tmux + ]; - text = '' - set +o errexit - set +o nounset + 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" ]]; then + if [[ "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/os" || "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/personal" ]]; then + clear + + return + fi + + tmux new-window -d -n scratch + nvim . clear + ''; + } + }/bin/.tmux-sessionizer"; - return - fi - - tmux new-window -d -n scratch - nvim . - clear - ''; - } - }/bin/.tmux-sessionizer"; + "tmux-sessionizer/directories".text = builtins.concatStringsSep "\n" cfg.directories; + }; }; } diff --git a/pkgs/tmux-sessionizer/configure-directories.patch b/pkgs/tmux-sessionizer/configure-directories.patch deleted file mode 100644 index 1e63ad2a..00000000 --- a/pkgs/tmux-sessionizer/configure-directories.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/tmux-sessionizer b/tmux-sessionizer -index fa1bec5..4d79e0b 100755 ---- a/tmux-sessionizer -+++ b/tmux-sessionizer -@@ -22,9 +22,7 @@ hydrate() { - if [[ $# -eq 1 ]]; then - selected=$1 - else -- # If someone wants to make this extensible, i'll accept -- # PR -- selected=$(find ~/ ~/personal ~/personal/dev/env/.config -mindepth 1 -maxdepth 1 -type d | fzf) -+ selected=$(find -L "${XDG_REPOS_DIR}" "${XDG_REPOS_DIR}"/* "${XDG_DOCUMENTS_DIR}" -maxdepth 1 -mindepth 1 -type d ! -name ".*" ! -name ".old" ! -name "_archive" | sort | fzf) - fi - - if [[ -z $selected ]]; then diff --git a/pkgs/tmux-sessionizer/default.nix b/pkgs/tmux-sessionizer/default.nix index 25ec6fb6..1564fe20 100644 --- a/pkgs/tmux-sessionizer/default.nix +++ b/pkgs/tmux-sessionizer/default.nix @@ -22,7 +22,11 @@ stdenv.mkDerivation { patches = [ ./move-default-script.patch ./add-tmux-file.patch - ./configure-directories.patch + + (fetchpatch { + url = "https://patch-diff.githubusercontent.com/raw/ThePrimeagen/tmux-sessionizer/pull/2.patch"; + sha256 = "sha256-4/4rzve49T3FHnl9WWUPJVcb0NQojMQjIVnEZGwVAsY="; + }) ]; installPhase = ''