Unverified Commit 2b982b99 authored by Jared Baur's avatar Jared Baur
Browse files

nixos/systemd: let systemd setup /etc/machine-id

If we let systemd setup /etc/machine-id, we get to use
ConditionFirstBoot in systemd units and any other integrations related
to systemd's detection of first boot. See machine-id(5).
parent 70fbdac0
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -125,14 +125,6 @@ ln -sfn "$systemConfig" /run/booted-system
@shell@ @postBootCommands@


# Ensure systemd doesn't try to populate /etc, by forcing its first-boot
# heuristic off. It doesn't matter what's in /etc/machine-id for this purpose,
# and systemd will immediately fill in the file when it starts, so just
# creating it is enough. This `: >>` pattern avoids forking and avoids changing
# the mtime if the file already exists.
: >> /etc/machine-id


# No need to restore the stdout/stderr streams we never redirected and
# especially no need to start systemd
if [ "${IN_NIXOS_SYSTEMD_STAGE1:-}" != true ]; then
+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ let
      "nss-lookup.target"
      "nss-user-lookup.target"
      "time-sync.target"
      "first-boot-complete.target"
    ] ++ optionals cfg.package.withCryptsetup [
      "cryptsetup.target"
      "cryptsetup-pre.target"
+3 −0
Original line number Diff line number Diff line
@@ -81,6 +81,9 @@ import ./make-test-python.nix ({ pkgs, ... }: {
    import re
    import subprocess

    # Will not succeed unless ConditionFirstBoot=yes
    machine.wait_for_unit("first-boot-complete.target")

    machine.wait_for_x()
    # wait for user services
    machine.wait_for_unit("default.target", "alice")