From 4ecd0c119a391bd53035bcec79fb6902066d3f95 Mon Sep 17 00:00:00 2001 From: Will Fancher Date: Fri, 28 Jul 2023 18:52:48 -0400 Subject: [PATCH] systemd shutdownRamfs: Fix infinite shutdown loop --- nixos/modules/system/boot/systemd/shutdown.nix | 6 +++++- nixos/tests/systemd-shutdown.nix | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/nixos/modules/system/boot/systemd/shutdown.nix b/nixos/modules/system/boot/systemd/shutdown.nix index b4b750fa9aaf..d7300e940af2 100644 --- a/nixos/modules/system/boot/systemd/shutdown.nix +++ b/nixos/modules/system/boot/systemd/shutdown.nix @@ -30,7 +30,11 @@ in { }; config = lib.mkIf cfg.enable { - systemd.shutdownRamfs.contents."/shutdown".source = "${config.systemd.package}/lib/systemd/systemd-shutdown"; + systemd.shutdownRamfs.contents = { + "/shutdown".source = "${config.systemd.package}/lib/systemd/systemd-shutdown"; + "/etc/initrd-release".source = config.environment.etc.os-release.source; + "/etc/os-release".source = config.environment.etc.os-release.source; + }; systemd.shutdownRamfs.storePaths = [pkgs.runtimeShell "${pkgs.coreutils}/bin"]; systemd.mounts = [{ diff --git a/nixos/tests/systemd-shutdown.nix b/nixos/tests/systemd-shutdown.nix index dad8167f198f..ca6754046f57 100644 --- a/nixos/tests/systemd-shutdown.nix +++ b/nixos/tests/systemd-shutdown.nix @@ -22,6 +22,6 @@ in { machine.wait_for_console_text("Unmounting '/oldroot'") machine.wait_for_console_text("${msg}") # Don't try to sync filesystems - machine.booted = False + machine.wait_for_shutdown() ''; })