An anyrun plugin that lets you search NixOS options.
nix build
... or cargo build
optionally :)
This plugin requires a config in your anyrun config directory called nixos_options.ron
.
The file looks like this:
Config(
options: {":prefix": ["/path/to/options.json"] }, // You can obtain NixOS's options.json using config.system.build.manual.optionsJSON
min_score: 0, // Optional, the minimum score of entries to show. Set it to a larger value on slow machines. Default: 0
nixpkgs_url: "https://github.com/NixOS/nixpkgs/blob/nixos-unstable" // Optional, URL to Nixpkgs tree. Set it to use the same branch as you're using. Defaults to the unstable url.
)
Important: Make sure to set a max_entries
in your anyrun config. Without that, the plugin will be VERY slow, since there exist over 16 thousand options to search through at the time of writing this.
I have set mine to 10, since even that value is enough for it to go off-screen, so you shouldn't lose any data.
Under flakes, the following instructions will apply:
- Use the anyrun home-manager module
- Add the plugin to your anyrun plugins list
programs.anyrun.config = {
# ...
plugins = [
inputs.anyrun-nixos-options.packages.${pkgs.system}.default
# other plugins that you might have
];
# ...
};
- Create a config file for it:
# ↓ make sure osConfig is in the argument set
{inputs, pkgs, osConfig, ...}: {
programs.anyrun.extraConfigFiles."nixos-options.ron".text = let
# ↓ home-manager refers to the nixos configuration as osConfig
nixos-options = osConfig.system.build.manual.optionsJSON + "/share/doc/nixos/options.json";
# merge your options
options = builtins.toJSON {
":nix" = [nixos-options];
};
# or alternatively if you wish to read any other documentation options, such as home-manager
# get the docs-json package from the home-manager flake
# hm-options = inputs.home-manager.packages.${pkgs.system}.docs-json + "/share/doc/home-manager/options.json";
# options = builtins.toJSON {
# ":nix" = [nixos-options];
# ":hm" = [hm-options];
# ":something-else" = [some-other-option];
# ":nall" = [nixos-options hm-options some-other-option];
# };
in ''
Config(
// add your option paths
options: ${options},
)
'';
}
- You are done. Rebuild your system and run anyrun as usual.
:nix
should bring up your NixOS (and any other configured) options
Without flakes, inputs... generally should be changed to or