mirror of
https://github.com/NixOS/nix.git
synced 2024-11-22 06:42:28 +00:00
1620ad4587
This makes it easier to understand the reach of global variables / global state in the config system.
29 lines
576 B
C++
29 lines
576 B
C++
#include "config-global.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,
|
|
});
|