Nix package manager
This commit is contained in:
@@ -34,6 +34,7 @@ Just run `topgrade`. It will run the following steps:
|
||||
* *Debian/Ubuntu*: Run `apt update && apt dist-upgrade`
|
||||
* *Linux*: Run [etc-update](https://dev.gentoo.org/~zmedico/portage/doc/man/etc-update.1.html):
|
||||
* *Unix*: Run `brew update && brew upgrade`. This should handle both Homebrew and Linuxbrew
|
||||
* *Unix*: Run `nix upgrade-nix && nix --upgrade`.
|
||||
* *Windows*: Upgrade Powershell modules
|
||||
* *Windows*: Upgrade all [Chocolatey](https://chocolatey.org/) packages
|
||||
* *Windows*: Upgrade all [Scoop](https://scoop.sh) packages
|
||||
|
||||
@@ -186,6 +186,11 @@ fn run() -> Result<(), Error> {
|
||||
|terminal| unix::run_homebrew(terminal, opt.dry_run),
|
||||
&mut execution_context,
|
||||
)?);
|
||||
#[cfg(unix)]
|
||||
report.push_result(execute(
|
||||
|terminal| unix::run_nix(terminal, opt.dry_run),
|
||||
&mut execution_context,
|
||||
)?);
|
||||
|
||||
if !opt.no_emacs {
|
||||
git_repos.insert(base_dirs.home_dir().join(".emacs.d"));
|
||||
|
||||
27
src/unix.rs
27
src/unix.rs
@@ -67,3 +67,30 @@ pub fn run_homebrew(terminal: &mut Terminal, dry_run: bool) -> Option<(&'static
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn run_nix(terminal: &mut Terminal, dry_run: bool) -> Option<(&'static str, bool)> {
|
||||
if let Some(nix) = which("nix") {
|
||||
if let Some(nix_env) = which("nix-env") {
|
||||
terminal.print_separator("Nix");
|
||||
|
||||
let inner = || -> Result<(), Error> {
|
||||
Executor::new(&nix, dry_run)
|
||||
.arg("upgrade-nix")
|
||||
.spawn()?
|
||||
.wait()?
|
||||
.check()?;
|
||||
Executor::new(&nix_env, dry_run)
|
||||
.arg("--upgrade")
|
||||
.spawn()?
|
||||
.wait()?
|
||||
.check()?;
|
||||
Ok(())
|
||||
};
|
||||
|
||||
return Some(("Nix", inner().is_ok()));
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user