NixOS is an operating system based on the Linux kernel, on systemd and on the package manager nix.
- Profile (default, user profile)
- root -> default profile
/nix/var/nix/profiles/default
- Each Profile has a Generation (change each time the environment change with nix-env)
- list
- delete
- switch
- stored in the nix-store in xxx-user-env package
nixos-rebuild
| Command
|
Build the configuration
|
Make the default boot
|
Switch the running system to it
|
Comments
|
| nixos-rebuild switch
|
Yes
|
Yes
|
Yes
|
|
| nixos-rebuild test
|
Yes
|
No
|
Yes
|
|
| nixos-rebuild boot
|
Yes
|
Yes
|
No (next reboot)
|
|
| nixos-rebuild switch -p test
|
Yes
|
?
|
?
|
Show up in a different Grub sub-menu
|
| nixos-rebuild build
|
Yes
|
No
|
No
|
|
| nixos-rebuild build-vm
|
Yes
|
No
|
No
|
Generate a Qemu image
|
| Command
|
Comments
|
| nixos-rebuild switch --upgrade
|
Update
Equivalent to: nix-channel --update nixos; nixos-rebuild-switch
|
| nixos-rebuild --show-trace switch -I nixpkgs=.
|
Build the configuration with debugging enabled using a modified nixpkgs source
|
nix-channel
| Command
|
Comments
|
| nix-channel --list
|
|
| nix-channel --add <URL> <NAME>
|
|
| nix-channel --remove <NAME>
|
|
| nix-channel --update <NAME>
|
|
nix-env
| Command
|
Comments
|
| nix-env -q
|
list installed derivations
|
| nix-env -qa
|
view the set of available packages in Nixpkgs
|
| nix-env -qaf <path/to/nixpkg>
|
view the set of available packages from a specific Nixpkgs folder
|
| nix-env -qas
|
get the status of the available package
|
| nix-env -i <package>
|
install the given package
|
| nix-env -e <package>
|
uninstall the given package
|
| nix-env -u <package>
|
upgrade the given package
|
| nix-env -u
|
upgrade all the package
|
| nix-env -u --dry-run
|
|
| nix-env --delete-generations old
|
delete older generations
|
| nix-env --delete-generations 10 11 12
|
delete generations 10 11 12
|
| nix-env --delete-generations 10d
|
delete generations older than 10d
|
| nix-env -G 3
|
switch to the generation 3
|
| nix-env -p /nix/var/nix/profiles/system --delete-generations old
|
delete older generations for the system profile
|
| nix-store --gc
|
|
| nix-store --gc --print-dead
|
|
| nix-store --gc --print-live
|
|
| nix-store -q --references `which <binary>`
|
|
| nix-store -q --referrers `which <binary>`
|
|
| nix-collect-garbage -d
|
|
| nix-env --list-generations
|
|
| nix-env --switch-profile /nix/var/nix/profiles/my-profile
|
|
| nix-env --rollback
|
To switch to the previous generation
|