about summary refs log tree commit diff
path: root/tests/lang/eval-okay-context-introspection.nix
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2019-01-13T17·43-0500
committerShea Levy <shea@shealevy.com>2019-01-14T16·27-0500
commit1d757292d0cb78beec32fcdfe15c2944a4bc4a95 (patch)
tree7c704f46212eb988db98e426b1043d4bc36ab1c7 /tests/lang/eval-okay-context-introspection.nix
parent087be7281a02a6d0e548ae56b910771837023d21 (diff)
Add builtins.getContext.
This can be very helpful when debugging, as well as enabling complex
black magic like surgically removing a single dependency from a
string's context.
Diffstat (limited to 'tests/lang/eval-okay-context-introspection.nix')
-rw-r--r--tests/lang/eval-okay-context-introspection.nix22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/lang/eval-okay-context-introspection.nix b/tests/lang/eval-okay-context-introspection.nix
new file mode 100644
index 000000000000..d9b2ea354990
--- /dev/null
+++ b/tests/lang/eval-okay-context-introspection.nix
@@ -0,0 +1,22 @@
+let
+  drv = derivation {
+    name = "fail";
+    builder = "/bin/false";
+    system = "x86_64-linux";
+    outputs = [ "out" "foo" ];
+  };
+
+  path = "${./eval-okay-context-introspection.nix}";
+
+  desired-context = {
+    "${builtins.unsafeDiscardStringContext path}" = {
+      path = true;
+    };
+    "${builtins.unsafeDiscardStringContext drv.drvPath}" = {
+      outputs = [ "foo" "out" ];
+      allOutputs = true;
+    };
+  };
+
+  legit-context = "${path}${drv.outPath}${drv.foo.outPath}${drv.drvPath}";
+in builtins.getContext legit-context == desired-context