From 6f993b8bde8201213fe2953ea663ac387de916e3 Mon Sep 17 00:00:00 2001 From: Jürgen Hahn Date: Mon, 2 Jan 2023 16:09:18 +0100 Subject: 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 --- tvix/derivation/src/write.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'tvix/derivation/src/write.rs') diff --git a/tvix/derivation/src/write.rs b/tvix/derivation/src/write.rs index 987c924fae3a..0ad1eb71e4da 100644 --- a/tvix/derivation/src/write.rs +++ b/tvix/derivation/src/write.rs @@ -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, + 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) -> Result<(), fmt::Error> { +pub fn write_arguments(writer: &mut impl Write, arguments: &[String]) -> Result<(), fmt::Error> { writer.write_char(COMMA)?; // convert Vec to [&str] let v: Vec<&str> = arguments.iter().map(|x| &**x).collect(); -- cgit 1.4.1