mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +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
|
struct UnresolvedApp
|
||||||
{
|
{
|
||||||
App unresolved;
|
App unresolved;
|
||||||
|
std::vector<BuiltPathWithResult> build(ref<Store> evalStore, ref<Store> store);
|
||||||
App resolve(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);
|
throw Error("attribute '%s' has unsupported type '%s'", cursor->getAttrPathStr(), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: move to libcmd
|
std::vector<BuiltPathWithResult> UnresolvedApp::build(ref<Store> evalStore, ref<Store> store)
|
||||||
App UnresolvedApp::resolve(ref<Store> evalStore, ref<Store> store)
|
|
||||||
{
|
{
|
||||||
auto res = unresolved;
|
|
||||||
|
|
||||||
Installables installableContext;
|
Installables installableContext;
|
||||||
|
|
||||||
for (auto & ctxElt : unresolved.context)
|
for (auto & ctxElt : unresolved.context)
|
||||||
installableContext.push_back(
|
installableContext.push_back(
|
||||||
make_ref<InstallableDerivedPath>(store, DerivedPath { ctxElt }));
|
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);
|
res.program = resolveString(*store, unresolved.program, builtContext);
|
||||||
if (!store->isInStore(res.program))
|
if (!store->isInStore(res.program))
|
||||||
throw Error("app program '%s' is not in the Nix store", 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 & installable = InstallableValue::require(*installable_);
|
||||||
auto unresolvedApp = installable.toApp(*evalState);
|
auto unresolvedApp = installable.toApp(*evalState);
|
||||||
auto app = unresolvedApp.resolve(evalStore, store);
|
auto app = unresolvedApp.resolve(evalStore, store);
|
||||||
|
auto buildables = unresolvedApp.build(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);
|
|
||||||
|
|
||||||
if (outLink != "")
|
if (outLink != "")
|
||||||
if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>())
|
if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue