Installation
On Arch Linux, you can alternatively install Nix through pacman
.
Verify installation
Check the installation by opening a new terminal and typing:
Nix Package Manager Commands
Description | Command | Example |
---|---|---|
Searching for pkgs | nix search nixpkgs packagename | nix --extra-experimental-features "nix-command flakes" search nixpkgs firefox |
List all Installed Pkgs | nix-env -q | - |
Query Installed pkgs | nix-env -q search_term | nix-env -q librewolf |
Query Available pkgs | nix-env -qa search_term | nix-env -qa calibre |
Installing pkgs | nix-env -iA nixpkgs.pkg_name | nix-env -iA nixpkgs.sakura |
Installing pkg from url | nix-env -i pkg_name --file example.com | nix-env --file https://github.com/NixOS/nixpkgs/archive/nixos-14.12.tar.gz --install --attr firefox<br> |
Upgrade single pkg | nix-env -u pkg_name | nix-env -u librewolf |
Upgrade All pkg | nix-env -u | - |
Uninstall a pkg | nix-env -e pkg_name | nix-env -e sakura |
Installed binaries are stored in ~/.nix-profile/bin
Generations Commands
Description | Command |
---|---|
list generations | nix-env --list-generations |
switch generations | nix-env --switch-generation 50 |
delete generation | nix-env --delete-generations old |
delete specific generations | nix-env --delete-generations 10 11 14 |
delete generation older than specific number of days | nix-env --delete-generations 14d |
Garbage Collection (cleanup)
After removing appropriate old generations you can run the garbage collector as follows:
nix-store --gc
If you are feeling uncertain, you can also first view what files would be deleted:
nix-store --gc --print-dead
Likewise, the option --print-live
will show the paths that won’t be deleted.
There is also a convenient little utility nix-collect-garbage
, which when invoked with the -d
(--delete-old
) switch deletes all old generations of all profiles in /nix/var/nix/profiles
. So
is a quick and easy way to clean up your system.