Skip to content

Commit

Permalink
Merge pull request #321662 from jmbaur/stc-ng-wsl
Browse files Browse the repository at this point in the history
Fix switch-to-configuration-ng on WSL
  • Loading branch information
Aleksanaa committed Jul 26, 2024
2 parents a46b61f + 3d1ecbd commit c5c722b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 28 deletions.
48 changes: 24 additions & 24 deletions pkgs/by-name/sw/switch-to-configuration-ng/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 15 additions & 4 deletions pkgs/by-name/sw/switch-to-configuration-ng/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1656,18 +1656,29 @@ 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()
.context("Failed to get full path to /proc/self/exe")?;

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}"))?;
}
}
Expand Down Expand Up @@ -1854,15 +1865,15 @@ won't take effect until you reboot the system.
// A unit in auto-restart substate is a failure *if* it previously failed to start
let unit_object_path = systemd
.get_unit(&unit)
.context("Failed to get unit info for {unit}")?;
.with_context(|| format!("Failed to get unit info for {unit}"))?;
let exec_main_status: i32 = dbus_conn
.with_proxy(
"org.freedesktop.systemd1",
unit_object_path,
Duration::from_millis(5000),
)
.get("org.freedesktop.systemd1.Service", "ExecMainStatus")
.context("Failed to get ExecMainStatus for {unit}")?;
.with_context(|| format!("Failed to get ExecMainStatus for {unit}"))?;

if exec_main_status != 0 {
failed_units.push(unit);
Expand Down

0 comments on commit c5c722b

Please sign in to comment.