diff --git a/parse-flake-lock/src/lib.rs b/parse-flake-lock/src/lib.rs index 6c6f5dc..13084f5 100644 --- a/parse-flake-lock/src/lib.rs +++ b/parse-flake-lock/src/lib.rs @@ -149,6 +149,7 @@ fn chase_input_node( Node::Repo(node) => node.inputs.to_owned(), Node::Indirect(node) => node.inputs.to_owned(), Node::Path(node) => node.inputs.to_owned(), + Node::Tarball(node) => node.inputs.to_owned(), Node::Fallthrough(node) => match node.get("inputs") { Some(node_inputs) => serde_json::from_value(node_inputs.clone()) .map_err(FlakeLockParseError::Json)?, @@ -203,6 +204,8 @@ pub enum Node { Indirect(IndirectNode), /// A [PathNode] flake input stemming from a filesystem path. Path(PathNode), + /// TODO + Tarball(TarballNode), /// A "catch-all" variant for node types that don't (yet) have explicit struct definitions in /// this crate. Fallthrough(serde_json::value::Value), // Covers all other node types @@ -216,6 +219,7 @@ impl Node { Node::Repo(_) => "Repo", Node::Indirect(_) => "Indirect", Node::Path(_) => "Path", + Node::Tarball(_) => "Tarball", Node::Fallthrough(_) => "Fallthrough", // Covers all other node types } } @@ -353,3 +357,37 @@ pub struct PathOriginal { #[serde(alias = "type")] pub node_type: String, } + +/// TODO +#[derive(Clone, Debug, Deserialize)] +pub struct TarballNode { + /// TODO + pub locked: TarballLocked, + /// TODO + pub inputs: Option>, + /// TODO + pub original: TarballOriginal, +} + +/// TODO +#[derive(Clone, Debug, Deserialize)] +pub struct TarballLocked { + /// The NAR hash of the input. + #[serde(alias = "narHash")] + pub nar_hash: String, + /// The type of the node (always `"tarball"`). + #[serde(alias = "type")] + pub node_type: String, + /// The URL used to fetch the tarball. + pub url: String, +} + +/// TODO +#[derive(Clone, Debug, Deserialize)] +pub struct TarballOriginal { + /// The URL for the tarball input. + pub url: String, + /// The type of the node (always `"tarball"`). + #[serde(alias = "type")] + pub node_type: String, +} diff --git a/src/flake.rs b/src/flake.rs index 3556e48..4af47b7 100644 --- a/src/flake.rs +++ b/src/flake.rs @@ -147,7 +147,7 @@ mod test { #[test] fn test_clean_flake_locks() { - for n in 0..=6 { + for n in 0..=7 { let path = PathBuf::from(format!("tests/flake.clean.{n}.lock")); let flake_lock = FlakeLock::new(&path).expect("couldn't create flake.lock"); let config = FlakeCheckConfig { diff --git a/src/summary.rs b/src/summary.rs index b99d75b..b749cbb 100644 --- a/src/summary.rs +++ b/src/summary.rs @@ -138,7 +138,7 @@ impl Summary { let summary_txt = handlebars.render("summary.txt", &self.data)?; - println!("{}", summary_txt); + print!("{}", summary_txt); Ok(()) } diff --git a/tests/flake.clean.7.lock b/tests/flake.clean.7.lock new file mode 100644 index 0000000..3c1f2d0 --- /dev/null +++ b/tests/flake.clean.7.lock @@ -0,0 +1,38 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1689078114, + "narHash": "sha256-osG8BrX5RpKJ7wH+vI6auOU+ctvNOblT4XXCgknK47c=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b6cc7ff8fee93789bc871a267ab876c3fca042cb", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixpkgs-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "sub": "sub" + } + }, + "sub": { + "locked": { + "narHash": "sha256-+qUhj8mkS6BsSFAOMQek346MHTEDkmoaojSBbLefq7w=", + "type": "tarball", + "url": "https://some-server.com/flake.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://some-server.com/flake.tar.gz" + } + } + }, + "root": "root", + "version": 7 +}