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.
This commit is contained in:
parent
087be7281a
commit
1d757292d0
5 changed files with 158 additions and 38 deletions
1
tests/lang/eval-okay-context-introspection.exp
Normal file
1
tests/lang/eval-okay-context-introspection.exp
Normal file
|
@ -0,0 +1 @@
|
|||
true
|
22
tests/lang/eval-okay-context-introspection.nix
Normal file
22
tests/lang/eval-okay-context-introspection.nix
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue