mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2026-02-01 23:25:11 +01:00
feat: add guix support (github #44)
This commit is contained in:
parent
5bb3773ba3
commit
e1b818530c
1 changed files with 22 additions and 3 deletions
|
|
@ -14,7 +14,7 @@ pub fn get_package_manager(data: &mut Data) -> Option<String> {
|
|||
}
|
||||
|
||||
for package_manager in &[
|
||||
"apt", "dnf", "emerge", "nix", "pacman", "yum",
|
||||
"apt", "dnf", "emerge", "guix", "nix", "pacman", "yum",
|
||||
// "zypper",
|
||||
] {
|
||||
if data.executables.iter().any(|exe| exe == package_manager) {
|
||||
|
|
@ -99,6 +99,24 @@ pub fn get_packages(
|
|||
Some(packages)
|
||||
}
|
||||
}
|
||||
"guix" => {
|
||||
let result = command_output(
|
||||
shell,
|
||||
&format!("{} locate {}", package_manager, executable),
|
||||
);
|
||||
if result.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let packages: Vec<String> = result
|
||||
.lines()
|
||||
.map(|line| line.split_whitespace().next().unwrap().to_string())
|
||||
.collect();
|
||||
if packages.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(packages)
|
||||
}
|
||||
}
|
||||
"nix" => {
|
||||
if !data.executables.contains(&"nix-locate".to_string()) {
|
||||
eprintln!(
|
||||
|
|
@ -183,6 +201,7 @@ pub fn install_package(data: &mut Data, package_manager: &str, package: &str) ->
|
|||
format!("{} install {}", package_manager, package)
|
||||
}
|
||||
"emerge" => format!("emerge {}", package),
|
||||
"guix" => format!("guix package -i {}", package),
|
||||
"nix" => format!("nix profile install nixpkgs#{}", package),
|
||||
"pacman" => format!("pacman -S {}", package),
|
||||
_ => match package_manager.ends_with("command-not-found") {
|
||||
|
|
@ -201,10 +220,10 @@ pub fn install_package(data: &mut Data, package_manager: &str, package: &str) ->
|
|||
},
|
||||
};
|
||||
|
||||
// nix does not require privilege escalation
|
||||
// guix and nix do not require privilege escalation
|
||||
#[allow(clippy::single_match)]
|
||||
match package_manager {
|
||||
"nix" => {}
|
||||
"guix" | "nix" => {}
|
||||
_ => elevate(data, &mut install),
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue