Nix Package Manager
Add packages
nix-env -iA nixpkgs.<packagename>
If using flakes:
nix profile add nixpkgs#package-name
Run a command
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.