Stop trying to remember the exact name of the nix flake output you want to use !
This little script simplify flake output selection using fzf.
We assume that you have nix configured with nix-command and flake available, add the following
to your /etc/nix/nix.conf:
experimental-features = nix-command flakesIn a directory containing a flake.nix file, run:
nix run github:jfroche/flake-fzfIt can also build remote flake if you provide a flake url:
nix run github:jfroche/flake-fzf github:Mic92/nix-ci-buildInside the fzf interface, you can use:
enterto select or build the selected flake outputtabto filter packages corresponding to your systemshift-tabto filter nixos system configurations
flake-fzf accepts the following parameters:
--printwill print the selected flake output instead of building it. This is useful if you want to use it in a shell and remember the command line (see below).
Select a flake output, then press enter to build it.
If you are using zsh here is a simple keybind to run it when pressing ctrl-l:
bindkey -s "^L" 'nix run github:jfroche/flake-fzf^M'If you want to keep the command line in your history, you can use this instead:
bindkey -s "^L" 'print -z $(nix run github:jfroche/flake-fzf . --print)^M'This will run the command and replace the command line with the selected flake output.
Of course if you installed flake-fzf in your PATH, you can use it directly:
bindkey -s "^L" 'print -z $(flake-fzf . --print)^M'