knowledge-base/Linux/nix-tips-and-tricks.md
2026-02-22 12:03:12 -07:00

42 lines
593 B
Markdown

# Nix Package Manager
## Add packages
```bash
nix-env -iA nixpkgs.<packagename>
```
If using flakes:
```bash
nix profile add nixpkgs#package-name
```
## Run a command
```bash
nix-shell -p hello --run "hello"
```
If using flakes:
```bash
nix shell nixpkgs#hello -c hello
```
# NixOS
## Updating a Flake based system
```bash
sudo nix update --flake /etc/nixos
sudo nixos-rebuild switch
```
## Updating a non-Flake based system
```bash
sudo nixos-rebuild switch --upgrade
```
You can use `boot` instead of `switch` for the system to boot into the new generation on reboot instead.