From 0139970416bbc87d26662ddfe3ab613166ed01a7 Mon Sep 17 00:00:00 2001 From: WilliButz Date: Wed, 7 Feb 2024 16:02:00 +0100 Subject: [PATCH] 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. --- nixos/modules/virtualisation/qemu-vm.nix | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index 3d7f3ccb62f8..523cfa023b35 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -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