mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-29 00:56:15 +02:00
1620ad4587
This makes it easier to understand the reach of global variables / global state in the config system.
28 lines
576 B
C++
28 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,
|
|
});
|