From 8f4b41cfd44275f3905829d46c7a158689b47e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Christ?= Date: Fri, 25 Oct 2024 14:00:41 +0200 Subject: [PATCH] nixos/systemd: Enable systemd-machine-id-commit.service Prior to this contribution, every boot with a default configuration was considered `ConditionFirstBoot=true` by systemd, since /etc/machine-id was not commited to disk. This also extends the systemd with a check for subsequent boots not being considered first boots. --- nixos/modules/system/boot/systemd.nix | 1 + nixos/tests/systemd.nix | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix index 6c70f50a6073..6173fca20dbb 100644 --- a/nixos/modules/system/boot/systemd.nix +++ b/nixos/modules/system/boot/systemd.nix @@ -160,6 +160,7 @@ let # Misc. "systemd-sysctl.service" + "systemd-machine-id-commit.service" ] ++ optionals cfg.package.withTimedated [ "dbus-org.freedesktop.timedate1.service" "systemd-timedated.service" diff --git a/nixos/tests/systemd.nix b/nixos/tests/systemd.nix index 0742af6aa840..63c52227e7fd 100644 --- a/nixos/tests/systemd.nix +++ b/nixos/tests/systemd.nix @@ -85,10 +85,17 @@ import ./make-test-python.nix ({ pkgs, ... }: { import re import subprocess + machine.start(allow_reboot=True) + # Will not succeed unless ConditionFirstBoot=yes machine.wait_for_unit("first-boot-complete.target") + # Make sure, a subsequent boot isn't a ConditionFirstBoot=yes. + machine.reboot() machine.wait_for_x() + state = machine.get_unit_info("first-boot-complete.target")['ActiveState'] + assert state == 'inactive', "Detected first boot despite first-boot-completed.target was already reached on a previous boot." + # wait for user services machine.wait_for_unit("default.target", "alice")