nixos/qemu-vm: convert tmpfiles rules to settings

This change replaces the previously hard-coded `/boot` path with a
reference to `efiSysMountPoint` and more importantly this change makes
it possible to override these rules in scenarios in which they are not
desired.

One such scenario would be when `systemd-gpt-auto-generator(8)` is used
to automount the ESP. Consider this section from the mentioned manpage:

> The ESP is mounted to /boot/ if that directory exists and is not used
> for XBOOTLDR, and otherwise to /efi/. Same as for /boot/, an automount
> unit is used. The mount point will be created if necessary.

Prior to this change, the ESP would be automounted under `/efi` on first
boot, then the previous tmpfiles rules caused `/boot` to be created.
Following the quote above, this meant that the ESP is mounted under
`/boot` for each subsequent boot.
This commit is contained in:
WilliButz
2024-02-07 16:25:30 +01:00
parent bf576e6b59
commit 0139970416
+12 -4
View File
@@ -1066,10 +1066,18 @@ in
''}
'';
systemd.tmpfiles.rules = lib.mkIf config.boot.initrd.systemd.enable [
"f /etc/NIXOS 0644 root root -"
"d /boot 0644 root root -"
];
systemd.tmpfiles.settings."10-qemu-vm" = lib.mkIf config.boot.initrd.systemd.enable {
"/etc/NIXOS".f = {
mode = "0644";
user = "root";
group = "root";
};
"${config.boot.loader.efi.efiSysMountPoint}".d = {
mode = "0644";
user = "root";
group = "root";
};
};
# After booting, register the closure of the paths in
# `virtualisation.additionalPaths' in the Nix database in the VM. This