RecentlyOdds & Ends
now playing

Nix

Nix is a reproducible operating system. The configuration is entirely declarative and thus self-documenting.

It’s also a package manager.

It’s also a functional programming language.

I’ve been using it since ~2023, and just now in 2026 am I finally semi-comfortable with it.

How it works

The Nix store

The Nix store is a read-only directory where Nix isolates and stores every single package, configuration file, and build dep for the system.

Every item is stored in its own directory:

/nix/store/13dayc1zvd2yi1h14zsdbdjlfv3ljyj2-firefox-137.0.1
/nix/store/*(dynamic content not available)*-*(dynamic content not available)*

Included in the It hashes all of the inputs used to build that package, including source code, compiler version, build scripts, and dependencies to guarantee determinism and reproducibility. No more dependency hell!

Flakes

==TODO==

Home Manager

The Nix package manager lets you install packages system-wide. For per-user configuration, you can use Home Manager. Home Manager also generally has much better support for package configuration.

Open questions

  • What is a flake
  • How does it actually work
  • What is Home Manager and why is it needed
  • What are the parallels between Nix and Docker

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

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