about summary refs log blame commit diff
path: root/tests/plugins/plugintest.cc
blob: c085d33295be9b19d034ca14326609fab78a0c71 (plain) (tree)
1
2
3
4
5
6
7
8
9
                    



                     


                                                        
                                                      


                      
 
                                              
 
                                                                                           
 
                              


                         

 
                                                             
#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);