From 6e5b63357b8a0f7cf6625968a1e55d21a33b2904 Mon Sep 17 00:00:00 2001 From: Asa Paparo Date: Mon, 25 May 2026 01:41:47 -0400 Subject: [PATCH] nixos/etc: create uninitialized /etc/machine-id with readonly /etc/ This resolves #523878 where /etc/ is readonly and /etc/machine-id cannot be created. Instead, /etc/machine-id is initialized to "uninitialized" by systemd-tmpfiles in initrd and persisted in /var/lib/nixos. --- nixos/modules/system/etc/etc-activation.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/nixos/modules/system/etc/etc-activation.nix b/nixos/modules/system/etc/etc-activation.nix index c294a3a6d436..b00c25e37802 100644 --- a/nixos/modules/system/etc/etc-activation.nix +++ b/nixos/modules/system/etc/etc-activation.nix @@ -173,5 +173,18 @@ }) + (lib.mkIf (config.system.etc.overlay.enable && !config.system.etc.overlay.mutable) { + # Systemd requires /etc/machine-id exists or can be initialized on first + # boot. This file should not be part of an image or system config because + # it is unique to the machine, so it is initialized at first boot and + # persisted in the system state directory, /var/lib/nixos. + environment.etc."machine-id".source = lib.mkDefault "/var/lib/nixos/machine-id"; + boot.initrd.systemd.tmpfiles.settings.machine-id."/sysroot/var/lib/nixos/machine-id".f = + lib.mkDefault + { + argument = "uninitialized"; + }; + }) + ]; }