Files
lix/lix/libflakes/init.cc
T
Raito Bezarius de0447c2c6 -------------- ongoing crimes
Change-Id: Iedd51025b3a5a25b6570983726f8a237c53f5192
2025-11-21 17:40:21 +01:00

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