mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-24 14:56:15 +02:00
737ed88f35
Allow global config settings to be defined in multiple Config classes. For example, this means that libutil can have settings and evaluator settings can be moved out of libstore. The Config classes are registered in a new GlobalConfig class to which config files etc. are applied. Relevant to https://github.com/NixOS/nix/issues/2009 in that it removes the need for ad hoc handling of useCaseHack, which was the underlying cause of that issue.
24 lines
527 B
C++
24 lines
527 B
C++
#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 Pos & pos, Value ** args, Value & v)
|
|
{
|
|
if (mySettings.settingSet)
|
|
mkNull(v);
|
|
else
|
|
mkBool(v, false);
|
|
}
|
|
|
|
static RegisterPrimOp rp("anotherNull", 0, prim_anotherNull);
|