Recently PostsOdds & Ends

Nix command reference

Command reference

Rebuilding

# rebuild from flake
sudo nixos-rebuild switch --flake .#astarion

List existing generations

# this is supposed to work, but it doesnt (on archaea). why?
sudo nix-env --list-generations

# this works
sudo nix-env --list-generations --profile /nix/var/nix/profiles/system

Garbage collection

Note: Nix garbage collection will delete anything not linked to a Binaries required for development shells will be garbage collected if the devshell is not actively in use. To prevent this, ? ==TODO==

Delete past generations:

nix-collect-garbage --delete-old
nix-collect-garbage --delete-generations 1 2 3

# running as sudo collects additional garbage
sudo nix-collect-garbage -d

For separation of concerns, the above commands delete generations from the filesystem, but does not remove them from the bootloader menu. That needs to be run separately:

sudo /run/current-system/bin/switch-to-configuration boot

If you skip this second part, selecting an old deleted generation in the bootloader menu will cause the system to crash.

Reducing disk usage

Finds duplicate entries in the Nix store and hardlinks them together

sudo nix-store --optimize -v