Commit Graph

13 Commits

Author SHA1 Message Date
r-vdp
a4f7868edf
nixos/etc-overlay: fix VM test for immutable overlay 2024-10-16 17:42:58 +02:00
r-vdp
24bf6e9cb8
nixos/etc-overlay: avoid rebuilding the initrd every time the etc contents change
Before this change, the hash of the etc metadata image was included in
the mount unit that's responsible for mounting this metadata image in the
initrd.
And because this metadata image changes with every change to the etc
contents, the initrd would be rebuild every time as well.
This can lead to a lot of rebuilds (especially when revision info is
included in /etc/os-release) and all these initrd archives use up a lot of
space on the ESP.

With this change, we instead include a symlink to the metadata image in the
top-level directory, in the same way as we already do for things like init and
prepare-root, and we deduce the store path from the init= kernel parameter,
in the same way as we already do to find the path to init and prepare-root.

Doing so avoids rebuilding the initrd all the time.
2024-10-16 17:42:58 +02:00
nikstur
9e720a5881 nixos/systemd-tmpfiles: create /etc/mtab via environmemt.etc instead of tmpfiles
This enables an immutable /etc via `system.etc.overlay.mutable = false`.
2024-08-07 16:12:37 +02:00
nikstur
2710a49adb nixos/systemd-sysusers: stop creating users statically
On Linux we cannot feasbibly generate users statically because we need
to take care to not change or re-use UIDs over the lifetime of a machine
(i.e. over multiple generations). This means we need the context of the
running machine.

Thus, stop creating users statically and instead generate them at
runtime irrespective of mutableUsers.

When /etc is immutable, the password files (e.g. /etc/passwd etc.) are
created in a separate directory (/var/lib/nixos/etc). /etc will be
pre-populated with symlinks to this separate directory.

Immutable users are now implemented by bind-mounting the password files
read-only onto themselves and only briefly re-mounting them writable to
re-execute sysusers. The biggest limitation of this design is that you
now need to manually unmount this bind mount to change passwords because
sysusers cannot change passwords for you. This shouldn't be too much of
an issue because system users should only rarely need to change their
passwords.
2024-07-21 16:23:11 +02:00
nikstur
6abbe725ca nixos/etc: handle mountpoints on top of /etc when switching
The activation script that remounts the /etc overlay now handles other
mount points on top of /etc by bind mounting them to the new temporary
/etc overlay and then atomically revealing it.
2024-07-18 21:28:53 +02:00
ivan770
1b288bca00
nixos/etc: support direct symlinks with etc overlay 2024-05-25 08:41:24 -04:00
nikstur
5df8caced4 nixos/etc: make re-mounting /etc overlay idempotent 2024-02-21 22:54:00 +01:00
nikstur
8710a27bc6 nixos/profiles/perlless: init 2024-01-22 00:54:13 +01:00
nikstur
60f529fc82 nixos/etc: optionally mount etc as an overlay 2024-01-22 00:54:13 +01:00
nikstur
7d0b5b3a94 nixos/nix-channnel: fix setting up the default channel again 2023-11-01 16:23:28 +01:00
nikstur
8c1739cafe nixos/nix-channel: fix subscribing to default channel
Fixes https://github.com/NixOS/nixpkgs/issues/264602
2023-10-31 16:51:23 +01:00
nikstur
cb08d3dd72 nixos/nix-channel: replace activationScript via tmpfiles 2023-10-25 23:43:58 +02:00
nikstur
59e3726755 nixos/activation: replace var activationScript via tmpfiles 2023-10-25 00:48:37 +02:00