chore(tvix/derivation): align json serialization with nix output

Use the #[serde(rename = "…")] field attributes to match the field names
that Nix uses in its JSON output (nix show-derivation).

This allows us to just re-use the exact same fixtures from go-nix,
without manual post-massaging.

Change-Id: Ifd5c08e43cd4f50d5e02903eccd8cb37230b70a6
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7757
Reviewed-by: jrhahn <mail.jhahn@gmail.com>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
Florian Klink 2023-01-04 19:26:05 +01:00 committed by flokli
parent 77cc6a1f78
commit 407a9cd90f
11 changed files with 113 additions and 103 deletions

View file

@ -9,13 +9,23 @@ use tvix_store::nixpath::STORE_DIR;
#[derive(Serialize, Deserialize)]
pub struct Derivation {
pub outputs: BTreeMap<String, Output>,
pub input_sources: Vec<String>,
pub input_derivations: BTreeMap<String, Vec<String>>,
pub platform: String,
pub builder: String,
#[serde(rename = "args")]
pub arguments: Vec<String>,
pub builder: String,
#[serde(rename = "env")]
pub environment: BTreeMap<String, String>,
#[serde(rename = "inputDrvs")]
pub input_derivations: BTreeMap<String, Vec<String>>,
#[serde(rename = "inputSrcs")]
pub input_sources: Vec<String>,
pub outputs: BTreeMap<String, Output>,
pub system: String,
}
impl Derivation {
@ -26,7 +36,7 @@ impl Derivation {
write::write_outputs(writer, &self.outputs)?;
write::write_input_derivations(writer, &self.input_derivations)?;
write::write_input_sources(writer, &self.input_sources)?;
write::write_platfrom(writer, &self.platform)?;
write::write_system(writer, &self.system)?;
write::write_builder(writer, &self.builder)?;
write::write_arguments(writer, &self.arguments)?;
write::write_enviroment(writer, &self.environment)?;