bundler: revert default behavior to use defaultApp

Bundlers are now responsible for correctly handling their inputs which
are no longer constrained to be (Drv->Drv)->Drv->Drv, but can be of
type (attrset->Drv)->attrset->Drv.
This commit is contained in:
Tom Bereknyei 2022-01-28 09:56:58 -05:00
parent dc85e20684
commit 4ebc50d92e
2 changed files with 16 additions and 4 deletions

View file

@ -51,7 +51,9 @@ struct CmdBundle : InstallableCommand
Strings getDefaultFlakeAttrPaths() override Strings getDefaultFlakeAttrPaths() override
{ {
Strings res{"defaultPackage." + settings.thisSystem.get()}; Strings res{
"defaultApp." + settings.thisSystem.get()
};
for (auto & s : SourceExprCommand::getDefaultFlakeAttrPaths()) for (auto & s : SourceExprCommand::getDefaultFlakeAttrPaths())
res.push_back(s); res.push_back(s);
return res; return res;
@ -59,7 +61,10 @@ struct CmdBundle : InstallableCommand
Strings getDefaultFlakeAttrPathPrefixes() override Strings getDefaultFlakeAttrPathPrefixes() override
{ {
Strings res{"packages." + settings.thisSystem.get() + "."}; Strings res{
"apps." + settings.thisSystem.get() + "."
};
for (auto & s : SourceExprCommand::getDefaultFlakeAttrPathPrefixes()) for (auto & s : SourceExprCommand::getDefaultFlakeAttrPathPrefixes())
res.push_back(s); res.push_back(s);
return res; return res;
@ -73,7 +78,7 @@ struct CmdBundle : InstallableCommand
const flake::LockFlags lockFlagsProg{ .writeLockFile = false }; const flake::LockFlags lockFlagsProg{ .writeLockFile = false };
auto programInstallable = InstallableFlake(this, auto programInstallable = InstallableFlake(this,
evalState, std::move(progFlakeRef), evalState, std::move(progFlakeRef),
Strings{progName == "" ? "defaultPackage" : progName}, Strings{progName == "" ? "defaultApp" : progName},
Strings(this->getDefaultFlakeAttrPathPrefixes()), Strings(this->getDefaultFlakeAttrPathPrefixes()),
lockFlagsProg); lockFlagsProg);
auto val = programInstallable.toValue(*evalState).first; auto val = programInstallable.toValue(*evalState).first;

View file

@ -10,8 +10,15 @@ cd $TEST_HOME
cat <<EOF > flake.nix cat <<EOF > flake.nix
{ {
outputs = {self}: { outputs = {self}: {
defaultBundler.$system = drv: drv; defaultBundler.$system = drv:
if drv?type && drv.type == "derivation"
then drv
else self.defaultPackage.$system;
defaultPackage.$system = import ./simple.nix; defaultPackage.$system = import ./simple.nix;
defaultApp.$system = {
type = "app";
program = "\${import ./simple.nix}/hello";
};
}; };
} }
EOF EOF