1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once
///@file

#include "lix/libexpr/eval.hh"
#include "lix/libutil/types.hh"

namespace nix {

struct AbstractNixRepl : NeverAsync
{
    typedef std::vector<std::pair<Value, std::string>> AnnotatedValues;

    static ReplExitStatus
    run(const SearchPath & searchPath,
        nix::ref<Store> store,
        EvalState & state,
        std::function<AnnotatedValues()> getValues,
        const ValMap & extraEnv,
        Bindings * autoArgs);

    static ReplExitStatus runSimple(
        EvalState & evalState,
        const ValMap & extraEnv);

protected:
    EvalState & state;
    Bindings * autoArgs;

    AbstractNixRepl(EvalState & state)
        : state(state)
    { }

    virtual ~AbstractNixRepl()
    { }

    virtual void initEnv() = 0;

    virtual ReplExitStatus mainLoop() = 0;
};

}