I’m a noob to Nix. For instance, I searched https://search.nixos.org/packages?query=bottom which yields bottom, the system monitor. I tried adding programs.bottom.enable = true;
but I get the message programs.bottom' does not exist
.
tl;dr: It’s a package, not a module, you want:
{ pkgs, ... }: {
environment.systemPackages = [
pkgs.bottom
];
}
Your search is correct, however there are two separate things to search in the nix world: packages and modules. You can switch between them with the tabs on top of search.nixos.org.
Packages are much like the packages you’re used to from other distros. They are just bundles of files, which usually include binaries, shared libraries, but also icons, dictionaries, shell completions, …
Nix packages are a bit different than other distro’s packages though. Other distro’s packages are designed to just be copied into the root of your system. Nix packages are only ever stored in /nix/store
; you need to do some bonus work to put them in a place where your system realizes they are there, allowing you to use them.
This is where NixOS and modules come into play. NixOS is really just a collection of these “modules”, which in turn is just a bunch of nix code which then gets turned into a script which symlinks a bunch of nix store paths into places that result in a working Linux distro.
This has one important consequence: On NixOS, you cannot install a package without using a module (caveat: you could, just like on other distros, use nix-env
or nix profile
instead of a module, but just pretend those commands don’t exist on NixOS, using them is almost always a terrible idea here).
Now, some packages have their own custom modules, which have a .enable
option which installs the package, for example programs.vim.enable. This is usually true for anything that needs more than just a couple of symlinks, since having a custom module allows you to add bonus things like systemd services (in the vim case, the module sets the default EDITOR
variable system-wide, and registers NixOS’ symlink functionality for vim plugin packages).
This isn’t true for all packages though, in fact the overwhelming majority (according to search.nixos.org there is an order of magnitude more packages than options, let alone modules) don’t have their own module. To install packages without a custom option, just add them to environment.systemPackages or users.users.<name>.packages:
{ pkgs, ... }: {
environment.systemPackages = [
pkgs.bottom
];
}