mirror of
https://github.com/NixOS/nix
synced 2025-06-25 06:31:14 +02:00
Refactor, extract some shared code into UnresolvedApp::build
This commit is contained in:
parent
e14346c7da
commit
7df7bde306
3 changed files with 12 additions and 10 deletions
|
@ -21,6 +21,7 @@ struct App
|
|||
struct UnresolvedApp
|
||||
{
|
||||
App unresolved;
|
||||
std::vector<BuiltPathWithResult> build(ref<Store> evalStore, ref<Store> store);
|
||||
App resolve(ref<Store> evalStore, ref<Store> store);
|
||||
};
|
||||
|
||||
|
|
|
@ -129,18 +129,23 @@ UnresolvedApp InstallableValue::toApp(EvalState & state)
|
|||
throw Error("attribute '%s' has unsupported type '%s'", cursor->getAttrPathStr(), type);
|
||||
}
|
||||
|
||||
// FIXME: move to libcmd
|
||||
App UnresolvedApp::resolve(ref<Store> evalStore, ref<Store> store)
|
||||
std::vector<BuiltPathWithResult> UnresolvedApp::build(ref<Store> evalStore, ref<Store> store)
|
||||
{
|
||||
auto res = unresolved;
|
||||
|
||||
Installables installableContext;
|
||||
|
||||
for (auto & ctxElt : unresolved.context)
|
||||
installableContext.push_back(
|
||||
make_ref<InstallableDerivedPath>(store, DerivedPath { ctxElt }));
|
||||
|
||||
auto builtContext = Installable::build(evalStore, store, Realise::Outputs, installableContext);
|
||||
return Installable::build(evalStore, store, Realise::Outputs, installableContext);
|
||||
}
|
||||
|
||||
// FIXME: move to libcmd
|
||||
App UnresolvedApp::resolve(ref<Store> evalStore, ref<Store> store)
|
||||
{
|
||||
auto res = unresolved;
|
||||
|
||||
auto builtContext = build(evalStore, store);
|
||||
res.program = resolveString(*store, unresolved.program, builtContext);
|
||||
if (!store->isInStore(res.program))
|
||||
throw Error("app program '%s' is not in the Nix store", res.program);
|
||||
|
|
|
@ -141,11 +141,7 @@ struct CmdFormatterBuild : MixFormatter
|
|||
auto & installable = InstallableValue::require(*installable_);
|
||||
auto unresolvedApp = installable.toApp(*evalState);
|
||||
auto app = unresolvedApp.resolve(evalStore, store);
|
||||
|
||||
Installables installableContext;
|
||||
for (auto & ctxElt : unresolvedApp.unresolved.context)
|
||||
installableContext.push_back(make_ref<InstallableDerivedPath>(store, DerivedPath{ctxElt}));
|
||||
auto buildables = Installable::build(evalStore, store, Realise::Outputs, installableContext);
|
||||
auto buildables = unresolvedApp.build(evalStore, store);
|
||||
|
||||
if (outLink != "")
|
||||
if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue