knowledge-base/Linux/nix-tips-and-tricks.md
2026-03-04 19:47:33 -07:00

604 B

[[TOC]]

Nix Package Manager

Add packages

nix-env -iA nixpkgs.<packagename>

If using flakes:

nix profile add nixpkgs#package-name

Run a command

nix-shell -p hello --run "hello"

If using flakes:

nix shell nixpkgs#hello -c hello

NixOS

Updating a Flake based system

sudo nix update --flake /etc/nixos
sudo nixos-rebuild switch

Updating a non-Flake based system

sudo nixos-rebuild switch --upgrade

You can use boot instead of switch for the system to boot into the new generation on reboot instead.