Last active
February 4, 2021 13:30
-
-
Save Brettm12345/cb96c29698995e16665be8cfec3a301b to your computer and use it in GitHub Desktop.
nixos-option with fzf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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