From 93299efc7c587194de4c88ddcba5d33df3b51bf6 Mon Sep 17 00:00:00 2001 From: Tom Bereknyei Date: Tue, 25 Jan 2022 03:39:18 -0500 Subject: [PATCH] bundler: add tests and change defaults to use a derivation --- src/nix/bundle.cc | 10 +++++----- tests/flake-bundler.sh | 23 +++++++++++++++++++++++ tests/local.mk | 1 + 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 tests/flake-bundler.sh diff --git a/src/nix/bundle.cc b/src/nix/bundle.cc index 445db5d5f..3d953ebc0 100644 --- a/src/nix/bundle.cc +++ b/src/nix/bundle.cc @@ -51,7 +51,7 @@ struct CmdBundle : InstallableCommand Strings getDefaultFlakeAttrPaths() override { - Strings res{"defaultApp." + settings.thisSystem.get()}; + Strings res{"defaultPackage." + settings.thisSystem.get()}; for (auto & s : SourceExprCommand::getDefaultFlakeAttrPaths()) res.push_back(s); return res; @@ -59,7 +59,7 @@ struct CmdBundle : InstallableCommand Strings getDefaultFlakeAttrPathPrefixes() override { - Strings res{"apps." + settings.thisSystem.get() + "."}; + Strings res{"packages." + settings.thisSystem.get() + "."}; for (auto & s : SourceExprCommand::getDefaultFlakeAttrPathPrefixes()) res.push_back(s); return res; @@ -73,7 +73,7 @@ struct CmdBundle : InstallableCommand const flake::LockFlags lockFlagsProg{ .writeLockFile = false }; auto programInstallable = InstallableFlake(this, evalState, std::move(progFlakeRef), - Strings{progName == "" ? "defaultApp" : progName}, + Strings{progName == "" ? "defaultPackage" : progName}, Strings(this->getDefaultFlakeAttrPathPrefixes()), lockFlagsProg); auto val = programInstallable.toValue(*evalState).first; @@ -82,8 +82,8 @@ struct CmdBundle : InstallableCommand const flake::LockFlags lockFlags{ .writeLockFile = false }; auto bundler = InstallableFlake(this, evalState, std::move(bundlerFlakeRef), - Strings{bundlerName == "" ? "defaultBundler." + settings.thisSystem.get() : settings.thisSystem.get() + "." + bundlerName}, - Strings({"bundlers."}), lockFlags); + Strings{bundlerName == "" ? "defaultBundler." + settings.thisSystem.get() : settings.thisSystem.get() + "." + bundlerName, bundlerName}, + Strings({"","bundlers."}), lockFlags); auto vRes = evalState->allocValue(); evalState->callFunction(*bundler.toValue(*evalState).first, *val, *vRes, noPos); diff --git a/tests/flake-bundler.sh b/tests/flake-bundler.sh new file mode 100644 index 000000000..2e52f999d --- /dev/null +++ b/tests/flake-bundler.sh @@ -0,0 +1,23 @@ +source common.sh + +clearStore +rm -rf $TEST_HOME/.cache $TEST_HOME/.config $TEST_HOME/.local + +cp ./simple.nix ./simple.builder.sh ./config.nix $TEST_HOME + +cd $TEST_HOME + +cat < flake.nix +{ + outputs = {self}: { + defaultBundler.$system = drv: drv; + defaultPackage.$system = import ./simple.nix; + }; +} +EOF +nix build .# +nix bundle --bundler .# .# +nix bundle --bundler .#defaultBundler.$system .#defaultPackage.$system + +clearStore + diff --git a/tests/local.mk b/tests/local.mk index 93cf20d43..9c3e6bbd3 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -48,6 +48,7 @@ nix_tests = \ flakes.sh \ flake-local-settings.sh \ flake-searching.sh \ + flake-bundler.sh \ build.sh \ repl.sh ca/repl.sh \ ca/build.sh \