Update flakes checking

This commit is contained in:
Victor Fuentes 2022-09-23 11:39:53 -04:00
parent 8491e61bd3
commit f9e4c4d0c2
No known key found for this signature in database
GPG Key ID: 0A88B68D6A9ACAE0

View File

@ -349,33 +349,6 @@ impl Component for AppModel {
sender: ComponentSender<Self>,
) -> ComponentParts<Self> {
let userpkgtype = if let Ok(h) = std::env::var("HOME") {
if Path::new(&format!("{}/.nix-profile/manifest.json", h)).exists() {
UserPkgs::Profile
} else {
UserPkgs::Env
}
} else {
UserPkgs::Env
};
let syspkgtype = match fs::read_to_string("/run/current-system/nixos-version") {
Ok(s) => {
if let Some(last) = s.split('.').last() {
if last.len() == 7 {
SystemPkgs::Flake
} else {
SystemPkgs::Legacy
}
} else {
SystemPkgs::Legacy
}
}
Err(_) => SystemPkgs::Legacy,
};
debug!("userpkgtype: {:?}", userpkgtype);
debug!("syspkgtype: {:?}", syspkgtype);
let (config, welcome) = if let Some(config) = getconfig() {
debug!("Got config: {:?}", config);
if !Path::new(&config.systemconfig).exists() {
@ -400,6 +373,46 @@ impl Component for AppModel {
}, true)
};
let userpkgtype = if let Ok(h) = std::env::var("HOME") {
if Path::new(&format!("{}/.nix-profile/manifest.json", h)).exists()
|| !Path::new("/nix/var/nix/profiles/per-user/root/channels/nixos").exists()
|| !Path::new(&format!("{}/.nix-profile/manifest.nix", h)).exists()
|| if let Ok(m) = fs::read_to_string(&format!("{}/.nix-profile/manifest.nix", h)) {
m == "[ ]"
} else {
false
}
{
UserPkgs::Profile
} else {
UserPkgs::Env
}
} else {
UserPkgs::Env
};
let syspkgtype = match fs::read_to_string("/run/current-system/nixos-version") {
Ok(s) => {
if !Path::new("/nix/var/nix/profiles/per-user/root/channels/nixos").exists() || config.flake.is_some() {
SystemPkgs::Flake
} else if let Some(last) = s.split('.').last() {
if last.len() == 7 || last == "dirty" || last == "git" {
SystemPkgs::Flake
} else {
SystemPkgs::Legacy
}
} else {
SystemPkgs::Legacy
}
}
Err(_) => SystemPkgs::Legacy,
};
debug!("userpkgtype: {:?}", userpkgtype);
debug!("syspkgtype: {:?}", syspkgtype);
let windowloading = WindowAsyncHandler::builder()
.detach_worker(())
.forward(sender.input_sender(), identity);