Skip to content

Commit

Permalink
feat: use show-derivation
Browse files Browse the repository at this point in the history
  • Loading branch information
louib committed Aug 14, 2023
1 parent af31c07 commit fb5f5f6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ extern crate clap;

use clap::Parser;

mod nix;
mod sbom;

/// nix2sbom extracts the SBOM (Software Bill of Materials) from a Nix derivation
#[derive(Parser)]
#[clap(name = "nix2sbom")]
Expand Down
13 changes: 13 additions & 0 deletions src/nix.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use std::io::Error;
use std::process::Command;

pub fn get_derivation(file: &str) -> Result<Vec<u8>, Error> {
let output = Command::new("nix")
.arg("show-derivation")
.arg("-r")
.arg("-f")
.arg(file)
.output()?;

Ok(output.stdout)
}
4 changes: 4 additions & 0 deletions src/sbom.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
enum Format {
SPDX,
CycloneDX,
}

0 comments on commit fb5f5f6

Please sign in to comment.