Add ability to build nix derivations

Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
Marcel Müller 2026-01-11 11:43:24 +01:00
parent 85c6a8f169
commit 8005aeccd9
8 changed files with 296 additions and 97 deletions

View file

@ -16,7 +16,7 @@ serde_json.workspace = true
serde_repr.workspace = true
thiserror = { workspace = true }
displaydoc = { workspace = true }
itertools = "0.14"
itertools = { workspace = true }
[dev-dependencies]
datatest-stable.workspace = true

View file

@ -17,7 +17,7 @@ pub enum LogBuildState {
#[derive(Debug)]
pub struct LogBuildStatus {
state: LogBuildState,
store_path: String,
derivation_path: String,
log_lines: Vec<String>,
}
@ -29,6 +29,14 @@ impl LogBuildStatus {
pub fn log_lines(&self) -> &[String] {
&self.log_lines
}
pub fn derivation_path(&self) -> &str {
&self.derivation_path
}
pub fn is_success(&self) -> bool {
self.state == LogBuildState::Succeeded
}
}
/// Accumulated build status of different nix-builds
@ -109,7 +117,10 @@ impl NixBuildState {
nix_log_start_action.id,
LogBuildStatus {
state: LogBuildState::Started,
store_path: nix_log_start_action.fields[0].as_str().unwrap().to_string(),
derivation_path: nix_log_start_action.fields[0]
.as_str()
.unwrap()
.to_string(),
log_lines: vec![],
},
);
@ -171,13 +182,17 @@ impl NixBuildState {
fn handle_log_action(
&self,
nix_log_msg_action: crate::NixLogMsgAction,
_nix_log_msg_action: crate::NixLogMsgAction,
) -> Option<NixBuildEvent> {
None
}
pub fn get_derivation(&self, drv: &str) -> Option<&LogBuildStatus> {
self.builds.values().find(|b| b.store_path == drv)
self.builds.values().find(|b| b.derivation_path == drv)
}
pub fn derivations(&self) -> impl Iterator<Item = &LogBuildStatus> {
self.builds.values()
}
}