- Tcl 77.9%
- Nix 22.1%
|
|
||
|---|---|---|
| tests/scroll | ||
| .gitignore | ||
| default.nix | ||
| flake.nix | ||
| LICENSE | ||
| package.nix | ||
| README.md | ||
| rofi-nix | ||
rofi-nix
Rofi plugin that nix-runs packages without installing them.
Prerequisites
Tcl/Tk, that's it 😎
…and Nix of course
Setup
- Put
rofi-nixsomewhere in your$PATHand make sure it's marked as executable. Alternatively, you can install it with Nix: there are both a flake and a classicpackage.nix/default.nix. - Add a nix mode to your rofi configuration, for example by calling it with
-modes "nix:rofi-nix"or by addingmodes: ["nix:rofi-nix"]to your~/config/rofi/config.rasi. - Make sure to pin the
nixpkgsflake withnix registry pin nixpkgs(and to re-pin it every once in a while), or startup will be slow every time nix decides to refresh the cache. - Run rofi. The first run after a pin will take a while, but subsequent runs use a cache and are fast.
Configuration
By default rofi-nix looks for packages in the nixpkgs flake, at top level and in these package sets:
- deepin
- enlightenment
- gnome
- jetbrains
- kdePackages
- lomiri
- lumina
- lxde
- lxqt
- mate
- pantheon
- sweethome3d
- xfce
- xorg
You can change this by writing a list of flakes and package sets in $XDG_CONFIG_HOME/rofi-nix/flakes_package_sets.
The format is flake1 {set1 set2} flake2 {set3 set4} (a Tcl dictionary).
The amount of whitespace is irrelevant.
The top level is always searched.
For example:
nixpkgs {
gnome
kdePackages
}
nur {repos.fgaz}
git+https://example.com/my-repo.git {}
NOTE: Remember to pin the flakes you use, or startup will be slow every time nix decides to refresh the cache!
Contributing
Send a patch to this mailing list or a pull request to the Codeberg mirror.
Performance
The Rofi window will not show until rofi-nix is done listing, so $argc==0 performance is important and must be considered when working on that code path!
As a guideline, on a warm cache the nix flake metadata call should dominate the runtime of rofi-nix.
For example, on my machine:
$ hyperfine -N "nix flake metadata --offline --json nixpkgs"
Benchmark 1: nix flake metadata --offline --json nixpkgs
Time (mean ± σ): 40.3 ms ± 1.9 ms [User: 24.1 ms, System: 11.3 ms]
Range (min … max): 37.6 ms … 45.0 ms 70 runs
$ hyperfine -N rofi-nix
Benchmark 1: rofi-nix
Time (mean ± σ): 61.2 ms ± 1.9 ms [User: 38.0 ms, System: 17.5 ms]
Range (min … max): 58.2 ms … 67.2 ms 47 runs