Cheatsheets

Nix

CommandsDescription
nix-info -mGet high level info of Nix in a mardown format
nix-env {-i | --install} <package>Install package. Nix will first try to get it in pre-compiled form from a binary cache. If no binary is available, it will build the package from source.
nix-env {-e | --uninstall} <package>Uninstall package
nix-env -u <package>Upgrade package to newer version
nix-env -uUpgrade all packages
nix-env -u --dry-runSee what nix will about to upgrade, without actually upgrading it.
nix-env -qaQuery available packages. You may also query packages by name.
Eg. nix-env -qa ruby
nix-collect-garbage -dDeletes old packages
nix-env --rollbackRollback to previous generation
nix-env --list-generationsList all available generations
nix-env -G <generation number>Switch to specific generation. Eg. nix-env -G 1
nix-env --delete-generations <generation number...>Delete specific generations. Eg. nix-env --delete-generations 1 2
nix-channel --updateObtain latest Nix expressions in every subscribed channels

nix-shell -p <package>

Starts an iteractive shell with the specified pacakge.

Eg.,

$ nix-shell -p cowsay

$ cowsay hello world
 _____________
< hello world >
 -------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Search for Node.js packages

To search for a node.js package, you'll have to run this command: nix-env -qaPA nixpkgs.nodePackages | grep <node package>

Eg.,

nix-env -qaPA nixpkgs.nodePackages | grep firebase-tools