26 lines
959 B
C++
26 lines
959 B
C++
#include "lix/libflakes/init.hh"
|
|
#include "lix/libflakes/expr/flakeref.hh"
|
|
#include "lix/libexpr/eval.hh"
|
|
#include "lix/libstore/store-api.hh"
|
|
|
|
// TODO: register the builtins
|
|
// register the setting for flakes (eval-cache)?
|
|
|
|
namespace nix::flake {
|
|
void initFlakes(Evaluator * eval)
|
|
{
|
|
// We inform the evaluator about Flakes during NIX_PATH processing.
|
|
eval->paths.registerAllowedNixPathPrefix("flake:");
|
|
eval->paths.registerSearchPathResolver([&](std::string const & value) {
|
|
return value.starts_with("flake:");
|
|
}, [&](std::string const & value, ref<Store> store) -> kj::Promise<Result<std::optional<std::string>>> {
|
|
auto flakeRef = parseFlakeRef(value.substr(6), {}, true, false);
|
|
debug("fetching flake search path element '%s'", value);
|
|
auto storePath =
|
|
TRY_AWAIT(TRY_AWAIT(flakeRef.resolve(store)).fetchTree(store)).first.storePath;
|
|
|
|
co_return {store->toRealPath(storePath)};
|
|
});
|
|
}
|
|
}
|