From 4dd2fd771615d2efec4cbf2e9fcfe206e67b8c7a Mon Sep 17 00:00:00 2001 From: Jeff Huffman Date: Fri, 29 Nov 2024 20:07:27 -0500 Subject: [PATCH] switch-to-configuration-ng: prevent error during NIXOS_LUSTRATE install --- .../sw/switch-to-configuration-ng/src/src/main.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkgs/by-name/sw/switch-to-configuration-ng/src/src/main.rs b/pkgs/by-name/sw/switch-to-configuration-ng/src/src/main.rs index 61932cb55591..44047cbbb684 100644 --- a/pkgs/by-name/sw/switch-to-configuration-ng/src/src/main.rs +++ b/pkgs/by-name/sw/switch-to-configuration-ng/src/src/main.rs @@ -970,10 +970,6 @@ fn do_system_switch(action: Action) -> anyhow::Result<()> { std::env::set_var("LOCALE_ARCHIVE", locale_archive); } - let current_system_bin = std::path::PathBuf::from("/run/current-system/sw/bin") - .canonicalize() - .context("/run/current-system/sw/bin is missing")?; - let os_release = parse_os_release().context("Failed to parse os-release")?; let distro_id_re = Regex::new(format!("^\"?{}\"?$", distro_id).as_str()) @@ -1033,6 +1029,11 @@ fn do_system_switch(action: Action) -> anyhow::Result<()> { std::process::exit(0); } + // Needs to be after the "boot" action exits, as this directory will not exist when doing a NIXOS_LUSTRATE install + let current_system_bin = std::path::PathBuf::from("/run/current-system/sw/bin") + .canonicalize() + .context("/run/current-system/sw/bin is missing")?; + let current_init_interface_version = std::fs::read_to_string("/run/current-system/init-interface-version").unwrap_or_default();