forked from lix-project/lix-installer
Detect if nix is installed (#51)
* Add Nix installed detection * Call nix-env --version instead
This commit is contained in:
parent
2dcda0a801
commit
6f64bb0092
|
@ -30,6 +30,16 @@ impl Planner for LinuxMulti {
|
||||||
return Err(Error::NixOs.into());
|
return Err(Error::NixOs.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For now, we don't try to repair the user's Nix install or anything special.
|
||||||
|
if let Ok(_) = tokio::process::Command::new("nix-env")
|
||||||
|
.arg("--version")
|
||||||
|
.stdin(std::process::Stdio::null())
|
||||||
|
.status()
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
return Err(Error::NixExists.into());
|
||||||
|
}
|
||||||
|
|
||||||
Ok(InstallPlan {
|
Ok(InstallPlan {
|
||||||
planner: Box::new(self.clone()),
|
planner: Box::new(self.clone()),
|
||||||
actions: vec![
|
actions: vec![
|
||||||
|
@ -74,6 +84,8 @@ impl Into<BuiltinPlanner> for LinuxMulti {
|
||||||
enum Error {
|
enum Error {
|
||||||
#[error("NixOS already has Nix installed")]
|
#[error("NixOS already has Nix installed")]
|
||||||
NixOs,
|
NixOs,
|
||||||
|
#[error("`nix` is already a valid command, so it is installed")]
|
||||||
|
NixExists,
|
||||||
#[error("Error planning action")]
|
#[error("Error planning action")]
|
||||||
Action(
|
Action(
|
||||||
#[source]
|
#[source]
|
||||||
|
|
Loading…
Reference in a new issue