Skip to content

Commit

Permalink
Use fast nix package count from libmacchina
Browse files Browse the repository at this point in the history
  • Loading branch information
Gobidev committed Jun 27, 2024
1 parent 4309bc1 commit 1361bd0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 30 deletions.
17 changes: 7 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ globset = "0.4.10"
dotenvy = "0.15.6"
glob = "0.3.1"
which = "4.4.0"
libmacchina = "7.2.3"
libmacchina = {git = "https://github.com/Macchina-CLI/libmacchina", rev = "3a5bec05e7a6fc6b5585bc1ee0a8f2583a77d9eb"}
crossterm = "0.27.0"
os-release = "0.1.0"

Expand Down
20 changes: 1 addition & 19 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,17 @@ fn packages(
| PackageManager::Xbps
| PackageManager::Apk
| PackageManager::Portage
| PackageManager::Nix
| PackageManager::Opkg => get_macchina_package_count(
macchina_package_count,
&format!("{pkg_manager:?}").to_lowercase(),
)
.unwrap_or(0),
// macchina only supports sqlite database backend for rpm
PackageManager::Rpm => match get_macchina_package_count(
macchina_package_count,
&format!("{pkg_manager:?}").to_lowercase(),
) {
Some(count) => count,
// for other databases run `rpm` (slow), see Macchina-CLI/libmacchina#154
None => {
if !skip_slow {
run_and_count_lines("rpm", &["-qa"])
Expand Down Expand Up @@ -132,23 +131,6 @@ fn packages(
0
}
}
PackageManager::Nix => {
if check_if_command_exists("nix-store") && !skip_slow {
run_and_count_lines(
"nix-store",
&["-q", "--requisites", "/run/current-system/sw"],
) + run_and_count_lines(
"nix-store",
&[
"-q",
"--requisites",
&format!("{}/.nix-profile", env::var("HOME").unwrap_or_default()),
],
)
} else {
0
}
}
}
}

Expand Down

0 comments on commit 1361bd0

Please sign in to comment.