From 58e2e66e50584acdf79334bb115e09f943e34ec9 Mon Sep 17 00:00:00 2001 From: Tomas Rivera <137088692+Totorile1@users.noreply.github.com> Date: Sun, 8 Mar 2026 16:53:01 +0100 Subject: [PATCH] added manix and a custom integration with fzf --- hosts/laptop/home.nix | 1 + modules/home-manager/ripgrep.nix | 1 - modules/home-manager/zsh.nix | 1 + modules/scripts/manix.nix | 44 ++++++++++++++++++++++++++++++++ modules/scripts/result | 1 + 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 modules/scripts/manix.nix create mode 120000 modules/scripts/result diff --git a/hosts/laptop/home.nix b/hosts/laptop/home.nix index bcd0c1c..647b3e5 100755 --- a/hosts/laptop/home.nix +++ b/hosts/laptop/home.nix @@ -72,6 +72,7 @@ home.packages = [ (pkgs.callPackage ../../modules/scripts/librewolfprofiles.nix {}) (pkgs.callPackage ../../modules/scripts/performance-mode.nix {}) (pkgs.callPackage ../../modules/scripts/btm.nix {}) +(pkgs.callPackage ../../modules/scripts/manix.nix {}) #pkgs pkgs.gruvbox-gtk-theme # # Adds the 'hello' command to your environment. It prints a friendly diff --git a/modules/home-manager/ripgrep.nix b/modules/home-manager/ripgrep.nix index e9d7493..a980514 100644 --- a/modules/home-manager/ripgrep.nix +++ b/modules/home-manager/ripgrep.nix @@ -8,7 +8,6 @@ "-." "-p" "-n" - "-c" ]; }; programs.ripgrep-all = { diff --git a/modules/home-manager/zsh.nix b/modules/home-manager/zsh.nix index 885ba37..98b8217 100644 --- a/modules/home-manager/zsh.nix +++ b/modules/home-manager/zsh.nix @@ -26,6 +26,7 @@ custom-cat() { cat = "custom-cat"; pomodoro = "custom-tomato"; librewolf = "kitty --class \"custom-librewolfprofiles\" --name \"Select LibreWolf profile\" --hold custom-librewolfprofiles"; + manix = "custom-manix"; }; }; } diff --git a/modules/scripts/manix.nix b/modules/scripts/manix.nix new file mode 100644 index 0000000..9ff79c8 --- /dev/null +++ b/modules/scripts/manix.nix @@ -0,0 +1,44 @@ +{ writeShellApplication, manix, ripgrep, fzf, stdenv, ... }: + +let + cacheTime = "10"; +in + +writeShellApplication { + name = "custom-manix"; + runtimeInputs = [ + manix + ripgrep + fzf + stdenv + ]; + text = '' +CACHE_DIR="''${XDG_CACHE_HOME:-$HOME/.cache}" +CACHE_FILE="$CACHE_DIR/custom-manix-options.txt" +mkdir -p "$CACHE_DIR" + +REGENERATE=0 + +# check if -r flag was passed +if [ "''${1:-}" = "-r" ]; then + REGENERATE=1 +fi + + +# regenerate if file does not exist or is older than cacheTime days +if [ ! -f "$CACHE_FILE" ] || [ "$(find "$CACHE_FILE" -mtime +${cacheTime} -print)" ]; then + REGENERATE=1 +fi + +if [ $REGENERATE -eq 1 ]; then + echo "(Re)building custom-manix cache..." + mkdir -p "$(dirname "$CACHE_FILE")" + manix "" | rg -N '^(?:\x1b\[[0-9;]*m)*# ' | sed 's/\x1b\[[0-9;]*m//g; s/^# //' | rg -Nv '^(<|.*https?://)' > "$CACHE_FILE" +fi + +# read from cache and pipe into fzf +cat "$CACHE_FILE" \ + | fzf --preview "manix {}" \ + | xargs manix + ''; +} diff --git a/modules/scripts/result b/modules/scripts/result new file mode 120000 index 0000000..fa27eed --- /dev/null +++ b/modules/scripts/result @@ -0,0 +1 @@ +/nix/store/mxdxf6bjib4l024yl5md4rllbashrpjq-options.json \ No newline at end of file