From 4ebc50d92e65e7fd9cf30fb84a0c39a13475a31f Mon Sep 17 00:00:00 2001 From: Tom Bereknyei Date: Fri, 28 Jan 2022 09:56:58 -0500 Subject: [PATCH] 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. --- src/nix/bundle.cc | 11 ++++++++--- tests/flake-bundler.sh | 9 ++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/nix/bundle.cc b/src/nix/bundle.cc index 3d953ebc0..113ceca33 100644 --- a/src/nix/bundle.cc +++ b/src/nix/bundle.cc @@ -51,7 +51,9 @@ struct CmdBundle : InstallableCommand Strings getDefaultFlakeAttrPaths() override { - Strings res{"defaultPackage." + settings.thisSystem.get()}; + Strings res{ + "defaultApp." + settings.thisSystem.get() + }; for (auto & s : SourceExprCommand::getDefaultFlakeAttrPaths()) res.push_back(s); return res; @@ -59,7 +61,10 @@ struct CmdBundle : InstallableCommand Strings getDefaultFlakeAttrPathPrefixes() override { - Strings res{"packages." + settings.thisSystem.get() + "."}; + Strings res{ + "apps." + settings.thisSystem.get() + "." + + }; for (auto & s : SourceExprCommand::getDefaultFlakeAttrPathPrefixes()) res.push_back(s); return res; @@ -73,7 +78,7 @@ struct CmdBundle : InstallableCommand const flake::LockFlags lockFlagsProg{ .writeLockFile = false }; auto programInstallable = InstallableFlake(this, evalState, std::move(progFlakeRef), - Strings{progName == "" ? "defaultPackage" : progName}, + Strings{progName == "" ? "defaultApp" : progName}, Strings(this->getDefaultFlakeAttrPathPrefixes()), lockFlagsProg); auto val = programInstallable.toValue(*evalState).first; diff --git a/tests/flake-bundler.sh b/tests/flake-bundler.sh index 2e52f999d..30e2fbd1d 100644 --- a/tests/flake-bundler.sh +++ b/tests/flake-bundler.sh @@ -10,8 +10,15 @@ cd $TEST_HOME cat < flake.nix { 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; + defaultApp.$system = { + type = "app"; + program = "\${import ./simple.nix}/hello"; + }; }; } EOF