feat(tvix/derivation): add nix drv path generation to Derivation
This adds a function to generate the derivation path. The computation is based on the Go implementation. Change-Id: Iae89db4976f5fd9208f0453f73688689a245cd66 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7729 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
parent
79c05f3810
commit
6f993b8bde
7 changed files with 137 additions and 4 deletions
|
|
@ -10,6 +10,12 @@ pub const BRACKET_CLOSE: char = ']';
|
|||
pub const COMMA: char = ',';
|
||||
pub const QUOTE: char = '"';
|
||||
|
||||
pub const COLON: &str = ":";
|
||||
pub const TEXT_COLON: &str = "text:";
|
||||
pub const SHA256_COLON: &str = "sha256:";
|
||||
pub const STORE_PATH_COLON: &str = "/nix/store:";
|
||||
pub const DOT_FILE_EXT: &str = ".drv";
|
||||
|
||||
fn write_array_elements(
|
||||
writer: &mut impl Write,
|
||||
quote: bool,
|
||||
|
|
@ -110,7 +116,7 @@ pub fn write_input_derivations(
|
|||
|
||||
pub fn write_input_sources(
|
||||
writer: &mut impl Write,
|
||||
input_sources: &Vec<String>,
|
||||
input_sources: &[String],
|
||||
) -> Result<(), fmt::Error> {
|
||||
writer.write_char(COMMA)?;
|
||||
|
||||
|
|
@ -138,8 +144,7 @@ pub fn write_builder(writer: &mut impl Write, builder: &str) -> Result<(), fmt::
|
|||
writer.write_str(escape_string(builder).as_str())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn write_arguments(writer: &mut impl Write, arguments: &Vec<String>) -> Result<(), fmt::Error> {
|
||||
pub fn write_arguments(writer: &mut impl Write, arguments: &[String]) -> Result<(), fmt::Error> {
|
||||
writer.write_char(COMMA)?;
|
||||
// convert Vec<String> to [&str]
|
||||
let v: Vec<&str> = arguments.iter().map(|x| &**x).collect();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue