about summary refs log tree commit diff
path: root/tvix/derivation/src/write.rs
diff options
context:
space:
mode:
authorJürgen Hahn <mail.jhahn@gmail.com>2023-01-02T15·09+0100
committerjrhahn <mail.jhahn@gmail.com>2023-01-04T12·24+0000
commit6f993b8bde8201213fe2953ea663ac387de916e3 (patch)
treef82cd8094172c18a5eb0601f278fa4205e48344c /tvix/derivation/src/write.rs
parent79c05f38109d2eac07b9ba893b9b6f67fd34c29c (diff)
feat(tvix/derivation): add nix drv path generation to Derivation r/5580
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>
Diffstat (limited to 'tvix/derivation/src/write.rs')
-rw-r--r--tvix/derivation/src/write.rs11
1 files changed, 8 insertions, 3 deletions
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<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();