aboutsummaryrefslogtreecommitdiff
path: root/tests/functional/plugins/plugintest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional/plugins/plugintest.cc')
-rw-r--r--tests/functional/plugins/plugintest.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/functional/plugins/plugintest.cc b/tests/functional/plugins/plugintest.cc
new file mode 100644
index 000000000..e02fd68d5
--- /dev/null
+++ b/tests/functional/plugins/plugintest.cc
@@ -0,0 +1,28 @@
+#include "config.hh"
+#include "primops.hh"
+
+using namespace nix;
+
+struct MySettings : Config
+{
+ Setting<bool> settingSet{this, false, "setting-set",
+ "Whether the plugin-defined setting was set"};
+};
+
+MySettings mySettings;
+
+static GlobalConfig::Register rs(&mySettings);
+
+static void prim_anotherNull (EvalState & state, const PosIdx pos, Value ** args, Value & v)
+{
+ if (mySettings.settingSet)
+ v.mkNull();
+ else
+ v.mkBool(false);
+}
+
+static RegisterPrimOp rp({
+ .name = "anotherNull",
+ .arity = 0,
+ .fun = prim_anotherNull,
+});