Deployment and lifecycle management for Nix
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

client: don't consider a switched system to always require reboot

+18 -6
+18 -6
client/src/sower.rs
··· 180 180 fn reboot_needed() -> std::io::Result<bool> { 181 181 let profile_paths = &["", "/initrd", "/kernel", "/kernel-modules"]; 182 182 let result = profile_paths.iter().any(|&path| { 183 - let current_path = format!("/nix/var/nix/profiles/system{}", path); 184 - let current_path = Path::new(&current_path); 185 - if !current_path.try_exists().unwrap_or(false) { 183 + let profile_path = format!("/nix/var/nix/profiles/system{}", path); 184 + let profile_path = Path::new(&profile_path); 185 + if !profile_path.try_exists().unwrap_or(false) { 186 186 return false; 187 187 }; 188 188 ··· 192 192 return false; 193 193 }; 194 194 195 - let current = fs::read_link(current_path).expect("unstable to read current link"); 196 - let booted = fs::read_link(booted_path).expect("unable to read booted link"); 195 + let current_path = format!("/run/current-system{}", path); 196 + let current_path = Path::new(&current_path); 197 + if !current_path.try_exists().unwrap_or(false) { 198 + return false; 199 + }; 197 200 198 - current != booted 201 + let profile = fs::canonicalize(profile_path).expect("unstable to read current link"); 202 + let current = fs::canonicalize(current_path).expect("unable to read current link"); 203 + let booted = fs::canonicalize(booted_path).expect("unable to read booted link"); 204 + 205 + if path != "" { 206 + current != booted 207 + } else { 208 + // if running system was updated using switch, don't reboot 209 + profile != current 210 + } 199 211 }); 200 212 Ok(result) 201 213 }