Skip to content

Commit

Permalink
feat: parse bootspec xen extension
Browse files Browse the repository at this point in the history
As defined in NixOS/nixpkgs#324911
  • Loading branch information
CertainLach committed Jan 17, 2025
1 parent 93e6f0d commit a9bbde1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions rust/tool/shared/src/generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use time::Date;
pub struct ExtendedBootJson {
pub bootspec: BootSpec,
pub lanzaboote_extension: LanzabooteExtension,
pub xen_extension: Option<XenExtension>,
}

#[derive(Debug, Clone, Deserialize)]
Expand All @@ -33,6 +34,16 @@ impl Default for LanzabooteExtension {
}
}

// TODO: Should it be moved to bootspec crate itself?
// Probably after its standardization, bootspec crate is only used in lanzaboote for now, bootspec support is
// ad-hoc in nixpkgs right now.
#[derive(Debug, Clone, Deserialize)]
pub struct XenExtension {
pub xen: String,
#[serde(rename = "xenParams")]
pub xen_params: Vec<String>,
}

/// A system configuration.
///
/// Can be built from a GenerationLink.
Expand Down Expand Up @@ -68,6 +79,10 @@ impl Generation {
.get("org.nix-community.lanzaboote")
.and_then(|v| serde_json::from_value::<LanzabooteExtension>(v.clone()).ok())
.unwrap_or_default();
let xen_extension = boot_json
.extensions
.get("org.xenproject.bootspec.v1")
.and_then(|v| serde_json::from_value::<XenExtension>(v.clone()).ok());

Ok(Self {
version: link.version,
Expand All @@ -76,6 +91,7 @@ impl Generation {
spec: ExtendedBootJson {
bootspec,
lanzaboote_extension,
xen_extension,
},
})
}
Expand All @@ -86,6 +102,7 @@ impl Generation {
spec: ExtendedBootJson {
bootspec: bootspec.clone(),
lanzaboote_extension: self.spec.lanzaboote_extension.clone(),
xen_extension: self.spec.xen_extension.clone(),
},
..self.clone()
}
Expand Down

0 comments on commit a9bbde1

Please sign in to comment.