about summary refs log tree commit diff
path: root/tvix/eval
diff options
context:
space:
mode:
authorAspen Smith <root@gws.fyi>2024-05-20T00·43-0400
committerclbot <clbot@tvl.fyi>2024-06-05T17·50+0000
commit72b9a126b81d9d41557c233387708c2bb640d13b (patch)
treee44956144db17703dde33cf1dbc98e8ae0767d6e /tvix/eval
parentc3572048d5c5fa4fc89425c17eeb4116d6584c65 (diff)
feat(tvix/glue): Implement builtins.storePath r/8217
This one's relatively simple - we just check if the store path exists,
and if it does we make a new contextful string containing the store path
as its only context element.

Automatic testing seems tricky for this (I think?) so I tested it
manually:

tvix-repl> builtins.storePath /nix/store/yn46i4xx5alh7gs6fpkxk430i34rp2q9-hello-2.12.1
=> "/nix/store/yn46i4xx5alh7gs6fpkxk430i34rp2q9-hello-2.12.1" :: string

Change-Id: I8a0d9726e4102ab872c53c2419679c2c855a5a18
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11696
Tested-by: BuildkiteCI
Autosubmit: aspen <root@gws.fyi>
Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/eval')
-rw-r--r--tvix/eval/src/value/string.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/tvix/eval/src/value/string.rs b/tvix/eval/src/value/string.rs
index 0b37d483b394..4f869eb00d7d 100644
--- a/tvix/eval/src/value/string.rs
+++ b/tvix/eval/src/value/string.rs
@@ -54,6 +54,12 @@ impl From<HashSet<NixContextElement>> for NixContext {
     }
 }
 
+impl<const N: usize> From<[NixContextElement; N]> for NixContext {
+    fn from(value: [NixContextElement; N]) -> Self {
+        Self(HashSet::from(value))
+    }
+}
+
 impl NixContext {
     /// Creates an empty context that can be populated
     /// and passed to form a contextful [NixString], albeit