It basically just gives you a declarative language to build your own distro with, plus a bunch of pre-made packages/modules you can then configure and assemble into what you need. The end result of what you are building will be a script that (re)installs your entire OS (called “activation” in NixOS parlance). That OS will have a lot of immutable parts, similar to Silverblue, but you can easily change anything in your install by modifying the original declarative configuration, rebuilding it, and then re-running the activation script.
That activation script can configure literally everything on your system, from bootloader to init to networking to services to your WM to app config. Mine even sets up the exact Librewolf UI layout. This means that when I get a new machine, I can just take the same config, add some hardware-specific stuff, and get my full work environment in minutes.
Impermanence takes it a step further, where your entire root filesystem will be wiped on shutdown to be recreated by that activation script during boot, except for the files and directories you explicitly tell it to keep on disk. This means you can control exactly where your apps keep their state and how much of it is there, which is handy for backups and also keeps your system feeling fresh.
Basically, here’s what my mount looks like:
none on / type tmpfs (rw,relatime,size=4194304k,mode=755)
/dev/nvme0n1p2 on /persist type ext4 (rw,relatime)
/dev/nvme0n1p2 on /var/lib/nixos type ext4 (rw,relatime)
/dev/nvme0n1p2 on /nix type ext4 (rw,relatime)
/dev/nvme0n1p2 on /nix/store type ext4 (ro,nosuid,nodev,relatime,x-initrd.mount)
/dev/nvme0n1p2 on /etc/machine-id type ext4 (rw,relatime)
/dev/nvme0n1p2 on /home/balsoft/.config/kdeconnect type ext4 (rw,relatime)
/dev/nvme0n1p2 on /home/balsoft/.config/nheko type ext4 (rw,relatime)
/dev/nvme0n1p2 on /etc/ssh type ext4 (rw,relatime)
/dev/nvme0n1p2 on /etc/NetworkManager/system-connections type ext4 (rw,relatime)
/dev/nvme0n1p2 on /home/balsoft/.config/JOSM type ext4 (rw,relatime)
/dev/nvme0n1p2 on /home/balsoft/.librewolf/default type ext4 (rw,relatime)
/dev/nvme0n1p2 on /home/balsoft/.local/share/JOSM type ext4 (rw,relatime)
/dev/nvme0n1p2 on /home/balsoft/.local/share/cargo type ext4 (rw,relatime)
<...>
So, I have a list of directories which will be kept on-disk, and the root filesystem (including /home) is just a tmpfs which is destroyed on shutdown.
Yep, it’s all bind mounts from /persist/<path> to /<path> where /persist is the actual root of the storage device.
While setting this up, I was surprised to learn that you can just bind mount files and it works, in my mind it was only supposed to work on directories.
And everything in there is referenced by hash, so it’s actually a little bit of work to inject something in there without your express written consent :)
Eh, kinda but a lot more flexible.
It basically just gives you a declarative language to build your own distro with, plus a bunch of pre-made packages/modules you can then configure and assemble into what you need. The end result of what you are building will be a script that (re)installs your entire OS (called “activation” in NixOS parlance). That OS will have a lot of immutable parts, similar to Silverblue, but you can easily change anything in your install by modifying the original declarative configuration, rebuilding it, and then re-running the activation script.
That activation script can configure literally everything on your system, from bootloader to init to networking to services to your WM to app config. Mine even sets up the exact Librewolf UI layout. This means that when I get a new machine, I can just take the same config, add some hardware-specific stuff, and get my full work environment in minutes.
Impermanence takes it a step further, where your entire root filesystem will be wiped on shutdown to be recreated by that activation script during boot, except for the files and directories you explicitly tell it to keep on disk. This means you can control exactly where your apps keep their state and how much of it is there, which is handy for backups and also keeps your system feeling fresh.
Basically, here’s what my
mountlooks like:none on / type tmpfs (rw,relatime,size=4194304k,mode=755) /dev/nvme0n1p2 on /persist type ext4 (rw,relatime) /dev/nvme0n1p2 on /var/lib/nixos type ext4 (rw,relatime) /dev/nvme0n1p2 on /nix type ext4 (rw,relatime) /dev/nvme0n1p2 on /nix/store type ext4 (ro,nosuid,nodev,relatime,x-initrd.mount) /dev/nvme0n1p2 on /etc/machine-id type ext4 (rw,relatime) /dev/nvme0n1p2 on /home/balsoft/.config/kdeconnect type ext4 (rw,relatime) /dev/nvme0n1p2 on /home/balsoft/.config/nheko type ext4 (rw,relatime) /dev/nvme0n1p2 on /etc/ssh type ext4 (rw,relatime) /dev/nvme0n1p2 on /etc/NetworkManager/system-connections type ext4 (rw,relatime) /dev/nvme0n1p2 on /home/balsoft/.config/JOSM type ext4 (rw,relatime) /dev/nvme0n1p2 on /home/balsoft/.librewolf/default type ext4 (rw,relatime) /dev/nvme0n1p2 on /home/balsoft/.local/share/JOSM type ext4 (rw,relatime) /dev/nvme0n1p2 on /home/balsoft/.local/share/cargo type ext4 (rw,relatime) <...>So, I have a list of directories which will be kept on-disk, and the root filesystem (including
/home) is just a tmpfs which is destroyed on shutdown.Read-only Nix store? How does that work?
It’s mounted twice, ro for the world and rw in the daemon mount namespace
ah that’s cool! When your
mounthas the same partition for different mountpoints how does that work? Some kind of bind-mount?Yep, it’s all bind mounts from
/persist/<path>to/<path>where/persistis the actual root of the storage device.While setting this up, I was surprised to learn that you can just bind mount files and it works, in my mind it was only supposed to work on directories.
And everything in there is referenced by hash, so it’s actually a little bit of work to inject something in there without your express written consent :)
Well, trusted-users (which I am) can kinda just inject shit into the store via a poisoned substituter.
But yeah otherwise it’s supposed to be secure
Yeah, that’s how most of our development works :)