Use os-release to determine appropriate planner (#501)

This commit is contained in:
Ana Hobden 2023-06-01 13:00:39 -07:00 committed by GitHub
parent 22aad4a332
commit 1d51b25bf7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View file

@ -17,7 +17,7 @@ build-inputs = ["darwin.apple_sdk.frameworks.Security"]
[features] [features]
default = ["cli", "diagnostics"] default = ["cli", "diagnostics"]
cli = ["eyre", "color-eyre", "clap", "tracing-subscriber", "tracing-error", "atty"] cli = ["eyre", "color-eyre", "clap", "tracing-subscriber", "tracing-error", "atty"]
diagnostics = ["os-release", "is_ci"] diagnostics = ["is_ci"]
[[bin]] [[bin]]
name = "nix-installer" name = "nix-installer"
@ -54,7 +54,7 @@ rand = { version = "0.8.5", default-features = false, features = [ "std", "std_r
semver = { version = "1.0.14", default-features = false, features = ["serde", "std"] } semver = { version = "1.0.14", default-features = false, features = ["serde", "std"] }
term = { version = "0.7.0", default-features = false } term = { version = "0.7.0", default-features = false }
uuid = { version = "1.2.2", features = ["serde"] } uuid = { version = "1.2.2", features = ["serde"] }
os-release = { version = "0.1.0", default-features = false, optional = true } os-release = { version = "0.1.0", default-features = false }
is_ci = { version = "1.1.1", default-features = false, optional = true } is_ci = { version = "1.1.1", default-features = false, optional = true }
strum = { version = "0.24.1", features = ["derive"] } strum = { version = "0.24.1", features = ["derive"] }
nix-config-parser = { version = "0.1.2", features = ["serde"] } nix-config-parser = { version = "0.1.2", features = ["serde"] }

View file

@ -172,7 +172,13 @@ impl BuiltinPlanner {
match (Architecture::host(), OperatingSystem::host()) { match (Architecture::host(), OperatingSystem::host()) {
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
(Architecture::X86_64, OperatingSystem::Linux) => { (Architecture::X86_64, OperatingSystem::Linux) => {
Ok(Self::Linux(linux::Linux::default().await?)) let os_release = os_release::OsRelease::new().ok();
match os_release {
Some(os_release) if os_release.id == "steamos" => {
Ok(Self::SteamDeck(steam_deck::SteamDeck::default().await?))
},
_ => Ok(Self::Linux(linux::Linux::default().await?)),
}
}, },
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
(Architecture::X86_32(_), OperatingSystem::Linux) => { (Architecture::X86_32(_), OperatingSystem::Linux) => {
@ -359,6 +365,9 @@ pub enum PlannerError {
/// An [`InstallSettingsError`] /// An [`InstallSettingsError`]
#[error(transparent)] #[error(transparent)]
InstallSettings(#[from] InstallSettingsError), InstallSettings(#[from] InstallSettingsError),
/// An OS Release error
#[error("Fetching `/etc/os-release`")]
OsRelease(#[source] std::io::Error),
/// A MacOS (Darwin) plist related error /// A MacOS (Darwin) plist related error
#[error(transparent)] #[error(transparent)]
Plist(#[from] plist::Error), Plist(#[from] plist::Error),
@ -398,6 +407,7 @@ impl HasExpectedErrors for PlannerError {
PlannerError::Plist(_) => None, PlannerError::Plist(_) => None,
PlannerError::Sysctl(_) => None, PlannerError::Sysctl(_) => None,
this @ PlannerError::RosettaDetected => Some(Box::new(this)), this @ PlannerError::RosettaDetected => Some(Box::new(this)),
PlannerError::OsRelease(_) => None,
PlannerError::Utf8(_) => None, PlannerError::Utf8(_) => None,
PlannerError::SelinuxRequirements => Some(Box::new(self)), PlannerError::SelinuxRequirements => Some(Box::new(self)),
PlannerError::Custom(_e) => { PlannerError::Custom(_e) => {