Basics
This page records some useful basic concepts and commands for nix
Note
Nix store: The approach taken by Nix is different. Nix stores all packages into a common place called the Nix store, usually located at /nix/store. Each package is stored in a unique subdirectory in the store, and each package has its own tree structure
Install nix
nix can be installed using the following command
sh <(curl -L https://nixos.org/nix/install) --daemon
Note
We may need to configure nix accordingly to use all of its features, e.g.,
- Set the environment variable
XDG_CONFIG_HOME, e.g.,export XDG_CONFIG_HOME=/home/szhang/.config - Edit
$XDG_CONFIG_HOME/nix/nix.conf(we may need to create one if it does not exist) and add the lineexperimental-features = nix-command flakes.Note that by doing this we switch on the unstable version of nix, in order to keep using the stable version, we need to specifynixpkgin our future nix command, e.g.,nix search nixpkgs emacsinstead ofnix search emacs
Use nix
Description |
Command |
Example |
|---|---|---|
Install a package |
|
|
Remove a package |
|
|
Upgrade a package |
|
|
Query installed packages |
|
|
Search a package |
|
|
Locate a package (within nix shell) |
|
|
Search an excutable |
|
N/A |
Description |
Command |
Example |
|---|---|---|
List existing channels |
|
N/A |
Add a new channel |
|
|
Remove a channel |
|
|
Description |
Command |
Example |
|---|---|---|
build a package |
|
|
clean up nix store (unused packages) |
|
N/A |
Description |
Command |
Example |
|---|---|---|
show the outputs of a flake URL |
|
|
clone the flake source to a local directory |
|
|