aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/primops.hh
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2021-09-28 22:12:41 +0200
committerMaximilian Bosch <maximilian@mbosch.me>2021-09-29 11:57:15 +0200
commit2b02ce0e481b653bcc5b403ef5d9e3670a88e8e5 (patch)
treeb0dcdea5d4fa242c2be33b8af2c78e179f0aaf6f /src/libexpr/primops.hh
parenta0bb5c4130268edbd368a4a07d4a30f1064e9c86 (diff)
libexpr: throw a more helpful eval-error if a builtin is not available due to a missing feature-flag
I found it somewhat confusing to have an error like error: attribute 'getFlake' missing if the required experimental-feature (`flakes`) is not enabled. Instead, I'd expect Nix to throw an error just like it's the case when using e.g. `nix flake` without `flakes` being enabled. With this change, the error looks like this: $ nix-instantiate -E 'builtins.getFlake "nixpkgs"' error: Cannot call 'builtins.getFlake' because experimental Nix feature 'flakes' is disabled. You can enable it via '--extra-experimental-features flakes'. at «string»:1:1: 1| builtins.getFlake "nixpkgs" | ^ I didn't use `settings.requireExperimentalFeature` here on purpose because this doesn't contain a position. Also, it doesn't seem as if we need to catch the error and check for the missing feature here since this already happens at evaluation time.
Diffstat (limited to 'src/libexpr/primops.hh')
-rw-r--r--src/libexpr/primops.hh4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/libexpr/primops.hh b/src/libexpr/primops.hh
index 9d42d6539..5b16e075f 100644
--- a/src/libexpr/primops.hh
+++ b/src/libexpr/primops.hh
@@ -15,7 +15,6 @@ struct RegisterPrimOp
std::vector<std::string> args;
size_t arity = 0;
const char * doc;
- std::optional<std::string> requiredFeature;
PrimOpFun fun;
};
@@ -28,8 +27,7 @@ struct RegisterPrimOp
RegisterPrimOp(
std::string name,
size_t arity,
- PrimOpFun fun,
- std::optional<std::string> requiredFeature = {});
+ PrimOpFun fun);
RegisterPrimOp(Info && info);
};