diff --git a/pkgs/by-name/sw/switch-to-configuration-ng/src/main.rs b/pkgs/by-name/sw/switch-to-configuration-ng/src/main.rs index 12b68c25a9bb..057604b03178 100644 --- a/pkgs/by-name/sw/switch-to-configuration-ng/src/main.rs +++ b/pkgs/by-name/sw/switch-to-configuration-ng/src/main.rs @@ -1656,7 +1656,16 @@ won't take effect until you reboot the system. die(); } Ok(users) => { - for (uid, name, _) in users { + for (uid, name, user_dbus_path) in users { + let gid: u32 = dbus_conn + .with_proxy( + "org.freedesktop.login1", + &user_dbus_path, + Duration::from_millis(5000), + ) + .get("org.freedesktop.login1.User", "GID") + .with_context(|| format!("Failed to get GID for {name}"))?; + eprintln!("reloading user units for {}...", name); let myself = Path::new("/proc/self/exe") .canonicalize() @@ -1664,10 +1673,12 @@ won't take effect until you reboot the system. std::process::Command::new(&myself) .uid(uid) + .gid(gid) .env("XDG_RUNTIME_DIR", format!("/run/user/{}", uid)) .env("__NIXOS_SWITCH_TO_CONFIGURATION_PARENT_EXE", &myself) .spawn() - .map(|mut child| _ = child.wait()) + .with_context(|| format!("Failed to spawn user activation for {name}"))? + .wait() .with_context(|| format!("Failed to run user activation for {name}"))?; } }