mirror of
https://github.com/NixOS/nix.git
synced 2025-11-11 13:06:01 +01:00
* It is tough to contribute to a project that doesn't use a formatter, * It is extra hard to contribute to a project which has configured the formatter, but ignores it for some files * Code formatting makes it harder to hide obscure / weird bugs by accident or on purpose, Let's rip the bandaid off? Note that PRs currently in flight should be able to be merged relatively easily by applying `clang-format` to their tip prior to merge.
43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
#pragma once
|
|
///@file
|
|
|
|
#include "nix/expr/eval.hh"
|
|
|
|
namespace nix {
|
|
|
|
struct AbstractNixRepl
|
|
{
|
|
ref<EvalState> state;
|
|
Bindings * autoArgs;
|
|
|
|
AbstractNixRepl(ref<EvalState> state)
|
|
: state(state)
|
|
{
|
|
}
|
|
|
|
virtual ~AbstractNixRepl() {}
|
|
|
|
typedef std::vector<std::pair<Value *, std::string>> AnnotatedValues;
|
|
|
|
using RunNix = void(Path program, const Strings & args, const std::optional<std::string> & input);
|
|
|
|
/**
|
|
* @param runNix Function to run the nix CLI to support various
|
|
* `:<something>` commands. Optional; if not provided,
|
|
* everything else will still work fine, but those commands won't.
|
|
*/
|
|
static std::unique_ptr<AbstractNixRepl> create(
|
|
const LookupPath & lookupPath,
|
|
nix::ref<Store> store,
|
|
ref<EvalState> state,
|
|
std::function<AnnotatedValues()> getValues,
|
|
RunNix * runNix = nullptr);
|
|
|
|
static ReplExitStatus runSimple(ref<EvalState> evalState, const ValMap & extraEnv);
|
|
|
|
virtual void initEnv() = 0;
|
|
|
|
virtual ReplExitStatus mainLoop() = 0;
|
|
};
|
|
|
|
} // namespace nix
|