-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
96 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
|
||
#[macro_use] | ||
extern crate clap; | ||
#[macro_use] | ||
extern crate serde_derive; | ||
|
||
use clap::Parser; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,52 @@ | ||
extern crate serde; | ||
extern crate serde_json; | ||
|
||
use std::collections::HashMap; | ||
|
||
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()?; | ||
#[derive(Debug)] | ||
#[derive(Serialize)] | ||
#[derive(Deserialize)] | ||
#[derive(Clone)] | ||
struct Derivation { | ||
outputs: HashMap<String, Output>, | ||
|
||
#[serde(rename = "inputSrcs")] | ||
inputs_sources: Vec<String>, | ||
|
||
#[serde(rename = "inputDrvs")] | ||
input_derivations: HashMap<String, Vec<String>>, | ||
|
||
system: String, | ||
|
||
builder: String, | ||
|
||
args: Vec<String>, | ||
|
||
env: HashMap<String, String>, | ||
|
||
#[serde(flatten)] | ||
extra: HashMap<String, serde_json::Value>, | ||
} | ||
|
||
impl Derivation { | ||
pub fn parse_from_file(file: &str) -> Result<Vec<u8>, Error> { | ||
let output = Command::new("nix") | ||
.arg("show-derivation") | ||
.arg("-r") | ||
.arg(file) | ||
.output()?; | ||
|
||
Ok(output.stdout) | ||
} | ||
} | ||
|
||
Ok(output.stdout) | ||
#[derive(Debug)] | ||
#[derive(Serialize)] | ||
#[derive(Deserialize)] | ||
#[derive(Clone)] | ||
struct Output { | ||
path: String, | ||
} |