From ce56358d224003b4c31cbc0f6302a3decaa27dc4 Mon Sep 17 00:00:00 2001 From: Jared Baur Date: Fri, 21 Jun 2024 20:32:57 -0700 Subject: [PATCH 1/3] switch-to-configuration-ng: update dependencies --- .../sw/switch-to-configuration-ng/Cargo.lock | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/pkgs/by-name/sw/switch-to-configuration-ng/Cargo.lock b/pkgs/by-name/sw/switch-to-configuration-ng/Cargo.lock index d66a2c6e7527..9b70ccfe23b3 100644 --- a/pkgs/by-name/sw/switch-to-configuration-ng/Cargo.lock +++ b/pkgs/by-name/sw/switch-to-configuration-ng/Cargo.lock @@ -22,9 +22,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.82" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "atty" @@ -153,9 +153,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -202,9 +202,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "libc" -version = "0.2.154" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libdbus-sys" @@ -229,9 +229,9 @@ checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "nix" @@ -290,9 +290,9 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -308,9 +308,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.4" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", @@ -320,9 +320,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", @@ -331,9 +331,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "rust-ini" @@ -348,18 +348,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.200" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.200" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", @@ -389,9 +389,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.60" +version = "2.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "ff8655ed1d86f3af4ee3fd3263786bc14245ad17c4c7e85ba7187fb3ae028c90" dependencies = [ "proc-macro2", "quote", @@ -476,9 +476,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-width" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "vec_map" From 6a6b710fbf9ab575619725d37205fa19caf5c6d4 Mon Sep 17 00:00:00 2001 From: Jared Baur Date: Fri, 21 Jun 2024 20:33:28 -0700 Subject: [PATCH 2/3] switch-to-configuration-ng: fix error messages In order to have the format strings include the proper content, we must use `with_context()`. --- pkgs/by-name/sw/switch-to-configuration-ng/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 a35b55065c07..12b68c25a9bb 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 @@ -1854,7 +1854,7 @@ 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", @@ -1862,7 +1862,7 @@ won't take effect until you reboot the system. 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); From 3d1ecbd9c8a509f9faac2919e93890f1774ccba8 Mon Sep 17 00:00:00 2001 From: Jared Baur Date: Fri, 21 Jun 2024 20:34:27 -0700 Subject: [PATCH 3/3] switch-to-configuration-ng: fix running on WSL The switch-to-configuration-ng program is able to be called in two different contexts, (1) when being called as root by as the entrypoint to NixOS switching (often from nixos-rebuild), and (2) when performing user activation. On WSL, calling the child process for the latter context appears to not work without also setting the GID of the child. Setting the GID for the child process is likely the right thing to do regardless of the host system being WSL. --- .../sw/switch-to-configuration-ng/src/main.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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}"))?; } }