Nix CLI Basics
Table of Contents
1 Basic Nix Command For Package Management
Just a list of basic commands with descriptions for the nix package
manager using imperative operations.
1.1 Package Managment
Search for packages is best done throught the web interface https://search.nixos.org/packages. The cli for searching is very slow.
| Description | Command |
|---|---|
| Searching for packages (slow) | nix-env -qaP packagename |
| Installing a package | nix-env -iA packagename |
| List installed packages | nix-env -q |
| Uninstall packages | nix-env -e packagename |
| Upgrade packages | nix-env -u |
1.2 Channels
Channels are where nix package definitions, etc are defined.
| Description | Command |
|---|---|
| Listing current channels | nix-channel –list |
| Adding a primary channel | nix-channel –add https://nixos.org/channels/channel-name nixos |
| Adding other channels | nix-channel –add https://some.channel/url my-alias |
| Remove a channel | nix-channel –remove channel-alias |
| Updating a channel | nix-channel –update channel-alias |
| Updating all channels | nix-channel –update |
1.3 Garbage Collection
Uninstalling nix packages does not remove them from your system, to do that you need the nix garbage collector.
| Description | Command |
|---|---|
| Delete everything not currently in use | nix-collect-garbage -d |