Skip to content

Instantly share code, notes, and snippets.

@Brettm12345
Last active February 4, 2021 13:30
Show Gist options
  • Save Brettm12345/cb96c29698995e16665be8cfec3a301b to your computer and use it in GitHub Desktop.
Save Brettm12345/cb96c29698995e16665be8cfec3a301b to your computer and use it in GitHub Desktop.
nixos-option with fzf
#! /usr/bin/env nix-shell
#! nix-shell -i sh -p jq fzf
OPTION_CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/nixos-options.json"
test -f "$OPTION_CACHE" || {
echo "Building cache..."
cp "$(export NIXPKGS_ALLOW_UNFREE=1; nix-build -Q --no-out-link '<nixpkgs/nixos/release.nix>' -A options)/share/doc/nixos/options.json" "$OPTION_CACHE"
}
OPTION=$(jq -r 'keys | join("\n")' "$OPTION_CACHE" | fzf --height "60%" --preview 'nixos-option {}')
test -n "$OPTION" && nixos-option "$OPTION"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment