Skip to content

Adding nix-search-tv aka nix-find as a widget - thought it was worth sharing #20

Description

@jakob1379

I started from the basic alias:

alias ns="nix-search-tv print | fzf --preview 'nix-search-tv preview {}' --scheme history"

and evolved it into a small helper that removed ~95% of my need to visit https://search.nixos.org/.

The main change is: instead of just printing the selected line from fzf, it drops me into a temporary environment by calling nix-shell -p with the selected package(s). This is ideal for “I just need this package right now”. It still works fine for browsing other indices via nix-search-tv.

Nix wrapper

(pkgs.writeShellApplication {
  name = "nix-find";
  runtimeInputs = [
    pkgs.nix-search-tv
    pkgs.fzf
    pkgs.busybox
    pkgs.wl-clipboard
    pkgs.xclip
  ];
  text = builtins.readFile ../../bin/nix-find;
})

I also bound nix-find to Ctrl+W for near-instant “temporary package” retrieval.

Script (nix-find)

#!/usr/bin/env bash

# Default to interactive mode
interactive=true

# Parse options
while getopts ":p" opt; do
  case ${opt} in
    p )
      interactive=false
      ;;
    \? )
      echo "Invalid option: $OPTARG" 1>&2
      exit 1
      ;;
  esac
done
shift $((OPTIND -1))

queries=("$@")

if [ "$interactive" = false ]; then
  # Non-interactive mode: filter and print
  nix-search-tv print "${queries[@]}" | fzf --filter="${queries[*]}"
  exit 0
fi

# Interactive mode
mapfile -t selections < <(
  nix-search-tv print "${queries[@]}" \
    | fzf \
        --ansi \
        --multi \
        --query="${queries[*]}" \
        --prompt="❄ Query> " \
        --scheme=history \
        --preview-window=down:60%:wrap \
        --preview 'nix-search-tv preview {}' \
        --bind "enter:accept" \
        --bind "alt-c:execute-silent(echo {} | awk -F'/ +' '{print \$2}' | tr -d ' ' | wl-copy 2>/dev/null || xclip -selection clipboard)" \
        --bind "alt-l:toggle-preview" \
        --header $'TAB mark • ENTER select • Alt-C copy • Alt-L toggle preview'
)
status=$?

if [ $status -eq 130 ]; then
  echo "Selection cancelled." >&2
  exit 130
elif [ ${#selections[@]} -eq 0 ]; then
  echo "No package selected." >&2
  exit 0
fi

pkgs=()
for sel in "${selections[@]}"; do

  attr=$(echo "$sel" | awk -F'/ +' '{print $2}' | tr -d ' ')
  pkgs+=("$attr")
done

echo "Running: nix-shell -p ${pkgs[*]}"
exec nix-shell -p "${pkgs[@]}"

Key bindings:

  • TAB mark multiple packages
  • ENTER spawn nix-shell -p ...
  • Alt-C copy selected package attribute to clipboard (wl-copy/xclip)
  • Alt-L toggle preview
Screencast_20260127_153435.webm

Sharing in case it’s useful as an example/workflow pattern for nix-search-tv users.

Activity

  1. 3timeslazy commented on Jan 30, 2026

    @3timeslazy
    Owner

    Hi @jakob1379,

    Thank you for sharing, nix-find is cool!

    There is a couple more cases alternative wrappers in the issues somewhere. Perhaps, I should think about updating the README and adding them there.

  2. jakob1379 commented on Jan 30, 2026

    @jakob1379
    Author

    I think some widget for this type of use-case in the flake would be great :D

  3. 3timeslazy commented on Jan 30, 2026

    @3timeslazy
    Owner
  4. 3timeslazy commented on Jan 30, 2026

    @3timeslazy
    Owner

    But it is not a part of the flake though

  5. 3timeslazy commented on Feb 19, 2026

    @3timeslazy
    Owner

    Added this wrapper in the new examples section in readme: https://github.com/3timeslazy/nix-search-tv?tab=readme-ov-file#custom-fzf-wrapper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions