aboutsummaryrefslogtreecommitdiff
path: root/src/nix/bundle.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix/bundle.cc')
-rw-r--r--src/nix/bundle.cc41
1 files changed, 20 insertions, 21 deletions
diff --git a/src/nix/bundle.cc b/src/nix/bundle.cc
index aca024bca..6b891a6ee 100644
--- a/src/nix/bundle.cc
+++ b/src/nix/bundle.cc
@@ -49,9 +49,13 @@ struct CmdBundle : InstallableCommand
Category category() override { return catSecondary; }
+ // FIXME: cut&paste from CmdRun.
Strings getDefaultFlakeAttrPaths() override
{
- Strings res{"defaultApp." + settings.thisSystem.get()};
+ Strings res{
+ "apps." + settings.thisSystem.get() + ".default",
+ "defaultApp." + settings.thisSystem.get()
+ };
for (auto & s : SourceExprCommand::getDefaultFlakeAttrPaths())
res.push_back(s);
return res;
@@ -69,29 +73,21 @@ struct CmdBundle : InstallableCommand
{
auto evalState = getEvalState();
- auto app = installable->toApp(*evalState).resolve(getEvalStore(), store);
+ auto val = installable->toValue(*evalState).first;
auto [bundlerFlakeRef, bundlerName] = parseFlakeRefWithFragment(bundler, absPath("."));
const flake::LockFlags lockFlags{ .writeLockFile = false };
- auto bundler = InstallableFlake(this,
- evalState, std::move(bundlerFlakeRef),
- Strings{bundlerName == "" ? "defaultBundler" : bundlerName},
- Strings({"bundlers."}), lockFlags);
-
- Value * arg = evalState->allocValue();
- evalState->mkAttrs(*arg, 2);
-
- PathSet context;
- for (auto & i : app.context)
- context.insert("=" + store->printStorePath(i.path));
- mkString(*evalState->allocAttr(*arg, evalState->symbols.create("program")), app.program, context);
-
- mkString(*evalState->allocAttr(*arg, evalState->symbols.create("system")), settings.thisSystem.get());
-
- arg->attrs->sort();
+ InstallableFlake bundler{this,
+ evalState, std::move(bundlerFlakeRef), bundlerName,
+ {"bundlers." + settings.thisSystem.get() + ".default",
+ "defaultBundler." + settings.thisSystem.get()
+ },
+ {"bundlers." + settings.thisSystem.get() + "."},
+ lockFlags
+ };
auto vRes = evalState->allocValue();
- evalState->callFunction(*bundler.toValue(*evalState).first, *arg, *vRes, noPos);
+ evalState->callFunction(*bundler.toValue(*evalState).first, *val, *vRes, noPos);
if (!evalState->isDerivation(*vRes))
throw Error("the bundler '%s' does not produce a derivation", bundler.what());
@@ -113,9 +109,12 @@ struct CmdBundle : InstallableCommand
auto outPathS = store->printStorePath(outPath);
- if (!outLink)
- outLink = baseNameOf(app.program);
+ if (!outLink) {
+ auto &attr = vRes->attrs->need(evalState->sName);
+ outLink = evalState->forceStringNoCtx(*attr.value,*attr.pos);
+ }
+ // TODO: will crash if not a localFSStore?
store.dynamic_pointer_cast<LocalFSStore>()->addPermRoot(outPath, absPath(*outLink));
}
};