about summary refs log tree commit diff
path: root/tvix/glue/src/builtins/derivation.nix
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-11-03T14·40+0200
committerclbot <clbot@tvl.fyi>2023-11-04T15·20+0000
commitc8cc31e07939feb707a60d2616de277f9227d6e6 (patch)
tree0b43d50b8bd1b092b19ceefdce0159fc45d1ae27 /tvix/glue/src/builtins/derivation.nix
parenta72a1044c29ce41973e0cf81bcee04923f21995f (diff)
refactor(tvix/glue): move builtins into separate directory r/6939
Change-Id: I25b7197458dbfbde8623545dc0a0286eb2744f10
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9911
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Diffstat (limited to 'tvix/glue/src/builtins/derivation.nix')
-rw-r--r--tvix/glue/src/builtins/derivation.nix36
1 files changed, 36 insertions, 0 deletions
diff --git a/tvix/glue/src/builtins/derivation.nix b/tvix/glue/src/builtins/derivation.nix
new file mode 100644
index 000000000000..9355cc3a96f0
--- /dev/null
+++ b/tvix/glue/src/builtins/derivation.nix
@@ -0,0 +1,36 @@
+# LGPL-2.1-or-later
+#
+# taken from: https://github.com/NixOS/nix/blob/master/src/libexpr/primops/derivation.nix
+#
+# TODO: rewrite in native Rust code
+
+/* This is the implementation of the ‘derivation’ builtin function.
+   It's actually a wrapper around the ‘derivationStrict’ primop. */
+
+drvAttrs @ { outputs ? [ "out" ], ... }:
+
+let
+
+  strict = derivationStrict drvAttrs;
+
+  commonAttrs = drvAttrs // (builtins.listToAttrs outputsList) //
+    {
+      all = map (x: x.value) outputsList;
+      inherit drvAttrs;
+    };
+
+  outputToAttrListElement = outputName:
+    {
+      name = outputName;
+      value = commonAttrs // {
+        outPath = builtins.getAttr outputName strict;
+        drvPath = strict.drvPath;
+        type = "derivation";
+        inherit outputName;
+      };
+    };
+
+  outputsList = map outputToAttrListElement outputs;
+
+in
+(builtins.head outputsList).value