···180180 fn reboot_needed() -> std::io::Result<bool> {
181181 let profile_paths = &["", "/initrd", "/kernel", "/kernel-modules"];
182182 let result = profile_paths.iter().any(|&path| {
183183- let current_path = format!("/nix/var/nix/profiles/system{}", path);
184184- let current_path = Path::new(¤t_path);
185185- if !current_path.try_exists().unwrap_or(false) {
183183+ let profile_path = format!("/nix/var/nix/profiles/system{}", path);
184184+ let profile_path = Path::new(&profile_path);
185185+ if !profile_path.try_exists().unwrap_or(false) {
186186 return false;
187187 };
188188···192192 return false;
193193 };
194194195195- let current = fs::read_link(current_path).expect("unstable to read current link");
196196- let booted = fs::read_link(booted_path).expect("unable to read booted link");
195195+ let current_path = format!("/run/current-system{}", path);
196196+ let current_path = Path::new(¤t_path);
197197+ if !current_path.try_exists().unwrap_or(false) {
198198+ return false;
199199+ };
197200198198- current != booted
201201+ let profile = fs::canonicalize(profile_path).expect("unstable to read current link");
202202+ let current = fs::canonicalize(current_path).expect("unable to read current link");
203203+ let booted = fs::canonicalize(booted_path).expect("unable to read booted link");
204204+205205+ if path != "" {
206206+ current != booted
207207+ } else {
208208+ // if running system was updated using switch, don't reboot
209209+ profile != current
210210+ }
199211 });
200212 Ok(result)
201213 }