Intro
View subscribed channels
nix-channel --list
Update subscribed channels
Downloads the Nix expressions of all subscribed channels (or only those included in names if specified) and makes them
the default for nix-env
operations (by symlinking them from the directory ~/.nix-defexpr).
nix-channel --update [names...]
Example:
nix-channel --update nixpkgs
Install package
You can search for pkg_name
in the Nix binary cache.
nix-env -iA nixpkgs.pkg_name
Uninstall package
nix-env -e pkg_name
Upgrade one package
nix-env -u pkg_name
Find local path of nixpkgs
You can use nix-instantiate
:
nix-instantiate --eval -E '<nixpkgs>'
or you can go inside nix repl and type <nixpkgs>
:
nix repl
Welcome to Nix 2.10.3. Type :? for help.
nix-repl> <nixpkgs>
/home/andrei/.nix-defexpr/channels/nixpkgs
Pretty print derivation file
nix show-derivation /nix/store/dzm1v1x310rxyh026i2ab8vcvs6m39yb-go-1.18.1.drv
Show closures of a derivation
The closures of a derivation is a list of all its dependencies, recursively, including absolutely everything necessary to use that derivation.
nix-store -qR `which man`
Copying all those derivations to the Nix store of another machine makes you able to run man out of the box on that other machine. That's the base of deployment using Nix, and you can already foresee the potential when deploying software in the cloud (hint: nix-copy-closures and nix-store --export).
nix-store -q --tree `which man`
more info on Nix Pills