knowledge-base/Linux/nix-tips-and-tricks.md
2026-01-16 20:07:52 -07:00

38 lines
547 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
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.