nix/tests/functional/plugins/plugintest.cc

29 lines
576 B
C++
Raw Permalink Normal View History

#include "config-global.hh"
#include "primops.hh"
using namespace nix;
struct MySettings : Config
{
Setting<bool> settingSet{this, false, "setting-set",
2018-02-13 19:43:32 +00:00
"Whether the plugin-defined setting was set"};
};
MySettings mySettings;
2018-02-13 19:43:32 +00:00
static GlobalConfig::Register rs(&mySettings);
2018-02-13 19:43:32 +00:00
static void prim_anotherNull (EvalState & state, const PosIdx pos, Value ** args, Value & v)
{
if (mySettings.settingSet)
2022-01-04 17:40:39 +00:00
v.mkNull();
2018-02-13 19:43:32 +00:00
else
2022-01-04 17:40:39 +00:00
v.mkBool(false);
}
static RegisterPrimOp rp({
.name = "anotherNull",
.arity = 0,
.fun = prim_anotherNull,
});