Fix nix profile upgrade command & add profile path detection (#56)
* Fixes antigen update (#39) * Adds manifest.json check to nix * #34 Fix `nix profile upgrade` command & add profile path detection (#4) Authored-by: Manu [tennox] <2084639+tennox@users.noreply.github.com>
This commit is contained in:
@@ -277,6 +277,12 @@ pub fn run_nix(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
let nix = require("nix")?;
|
let nix = require("nix")?;
|
||||||
let nix_channel = require("nix-channel")?;
|
let nix_channel = require("nix-channel")?;
|
||||||
let nix_env = require("nix-env")?;
|
let nix_env = require("nix-env")?;
|
||||||
|
let profile_path = match env::home_dir() {
|
||||||
|
Some(home) => Path::new(&home).join(".nix-profile"),
|
||||||
|
None => Path::new("/nix/var/nix/profiles/per-user/default").into(),
|
||||||
|
};
|
||||||
|
debug!("nix profile: {:?}", profile_path);
|
||||||
|
let manifest_json_path = profile_path.join("manifest.json");
|
||||||
|
|
||||||
let output = Command::new(&nix_env).args(&["--query", "nix"]).check_output();
|
let output = Command::new(&nix_env).args(&["--query", "nix"]).check_output();
|
||||||
debug!("nix-env output: {:?}", output);
|
debug!("nix-env output: {:?}", output);
|
||||||
@@ -317,7 +323,17 @@ pub fn run_nix(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
run_type.execute(&nix_channel).arg("--update").check_run()?;
|
run_type.execute(&nix_channel).arg("--update").check_run()?;
|
||||||
run_type.execute(&nix_env).arg("--upgrade").check_run()
|
|
||||||
|
if std::path::Path::new(&manifest_json_path).exists() {
|
||||||
|
run_type
|
||||||
|
.execute(&nix)
|
||||||
|
.arg("profile")
|
||||||
|
.arg("upgrade")
|
||||||
|
.arg(".*")
|
||||||
|
.check_run()
|
||||||
|
} else {
|
||||||
|
run_type.execute(&nix_env).arg("--upgrade").check_run()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_yadm(ctx: &ExecutionContext) -> Result<()> {
|
pub fn run_yadm(ctx: &ExecutionContext) -> Result<()> {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ pub fn run_antigen(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
|
|||||||
|
|
||||||
print_separator("antigen");
|
print_separator("antigen");
|
||||||
|
|
||||||
let cmd = format!("source {} && antigen selfupdate && antigen update", zshrc.display());
|
let cmd = format!("source {} && (antigen selfupdate ; antigen update)", zshrc.display());
|
||||||
run_type.execute(zsh).args(&["-l", "-c", cmd.as_str()]).check_run()
|
run_type.execute(zsh).args(&["-l", "-c", cmd.as_str()]).check_run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user