libexpr: derivationOf primop#14956
libexpr: derivationOf primop#14956JustAGuyTryingHisBest wants to merge 17 commits intoNixOS:masterfrom
Conversation
|
This should reject nonsensical inputs, just like my Nixpkgs implementation would.
Overly lenient functions produce garbage inputs to other functions, which then produce garbage errors, and we can't make functions less lenient without breaking user expressions, so this really has to be done with care and a bunch of "adversarial" tests. |
0fff477 to
210b7fc
Compare
210b7fc to
08f9ac6
Compare
|
Awesome. Could you make sure the returned string has the correct context? |
|
@roberth I appreciate your patience and working through this change with me!
Done. Does this seem like the right context?
Done. Do you see any additional tests that might be beneficial?
see nix-repl> builtins.derivationOf "/nix/store/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-test"
error:
… while calling the 'derivationOf' builtin
at «string»:1:1:
1| builtins.derivationOf "/nix/store/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-test"
| ^
error: '/nix/store/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-test' has no derivation in its context
I would opt to open an issue against the ca-derivation milestone. |
|
LGTM but has typo Details
diff --git a/tests/functional/lang/eval-okay-derivationOf-coerce.nix b/tests/functional/lang/eval-okay-derivationOf-coerce.nix
index 025157623..b00ca6fe3 100644
--- a/tests/functional/lang/eval-okay-derivationOf-coerce.nix
+++ b/tests/functional/lang/eval-okay-derivationOf-coerce.nix
@@ -5,4 +5,4 @@ let
system = "x86_64-linux";
};
in
-builtins.derivationOf pkg.outPath == drv.drvPath
+builtins.derivationOf pkg.outPath == pkg.drvPath
diff --git a/tests/functional/lang/eval-okay-derivationOf.nix b/tests/functional/lang/eval-okay-derivationOf.nix
index 2abbac5c9..6386ee9a9 100644
--- a/tests/functional/lang/eval-okay-derivationOf.nix
+++ b/tests/functional/lang/eval-okay-derivationOf.nix
@@ -5,4 +5,4 @@ let
system = "x86_64-linux";
};
in
-builtins.derivationOf pkg == drv.drvPath
+builtins.derivationOf pkg == pkg.drvPath |
|
See #15113. After that (or something like it) is merged, we can use |
Should I close this PR out or move it to a draft? |
|
Well I think I should go over the above plan with @roberth a bit, in case he disagrees and wants to go directly with this, so you don't have to draft it or close it. |
Sounds like a plan. I appreciate your time and energy on this PR! |
Motivation
Taken directly from the related issue - This function improves RFC 92 and multi-derivation package support, by allowing the derivation path to be accessed for any output, whose derivations may be distinct, rather than only exposing a single drvPath.
Context
Resolves #10120
Translates solution from NixOS/nixpkgs#281536 to CppNix. Thank you to @roberth for the initial implementation.
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.