bundler: add tests and change defaults to use a derivation
This commit is contained in:
parent
c94db0535c
commit
93299efc7c
|
@ -51,7 +51,7 @@ struct CmdBundle : InstallableCommand
|
||||||
|
|
||||||
Strings getDefaultFlakeAttrPaths() override
|
Strings getDefaultFlakeAttrPaths() override
|
||||||
{
|
{
|
||||||
Strings res{"defaultApp." + settings.thisSystem.get()};
|
Strings res{"defaultPackage." + 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 +59,7 @@ struct CmdBundle : InstallableCommand
|
||||||
|
|
||||||
Strings getDefaultFlakeAttrPathPrefixes() override
|
Strings getDefaultFlakeAttrPathPrefixes() override
|
||||||
{
|
{
|
||||||
Strings res{"apps." + settings.thisSystem.get() + "."};
|
Strings res{"packages." + 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 +73,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 == "" ? "defaultApp" : progName},
|
Strings{progName == "" ? "defaultPackage" : progName},
|
||||||
Strings(this->getDefaultFlakeAttrPathPrefixes()),
|
Strings(this->getDefaultFlakeAttrPathPrefixes()),
|
||||||
lockFlagsProg);
|
lockFlagsProg);
|
||||||
auto val = programInstallable.toValue(*evalState).first;
|
auto val = programInstallable.toValue(*evalState).first;
|
||||||
|
@ -82,8 +82,8 @@ struct CmdBundle : InstallableCommand
|
||||||
const flake::LockFlags lockFlags{ .writeLockFile = false };
|
const flake::LockFlags lockFlags{ .writeLockFile = false };
|
||||||
auto bundler = InstallableFlake(this,
|
auto bundler = InstallableFlake(this,
|
||||||
evalState, std::move(bundlerFlakeRef),
|
evalState, std::move(bundlerFlakeRef),
|
||||||
Strings{bundlerName == "" ? "defaultBundler." + settings.thisSystem.get() : settings.thisSystem.get() + "." + bundlerName},
|
Strings{bundlerName == "" ? "defaultBundler." + settings.thisSystem.get() : settings.thisSystem.get() + "." + bundlerName, bundlerName},
|
||||||
Strings({"bundlers."}), lockFlags);
|
Strings({"","bundlers."}), lockFlags);
|
||||||
|
|
||||||
auto vRes = evalState->allocValue();
|
auto vRes = evalState->allocValue();
|
||||||
evalState->callFunction(*bundler.toValue(*evalState).first, *val, *vRes, noPos);
|
evalState->callFunction(*bundler.toValue(*evalState).first, *val, *vRes, noPos);
|
||||||
|
|
23
tests/flake-bundler.sh
Normal file
23
tests/flake-bundler.sh
Normal file
|
@ -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 <<EOF > 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
|
||||||
|
|
|
@ -48,6 +48,7 @@ nix_tests = \
|
||||||
flakes.sh \
|
flakes.sh \
|
||||||
flake-local-settings.sh \
|
flake-local-settings.sh \
|
||||||
flake-searching.sh \
|
flake-searching.sh \
|
||||||
|
flake-bundler.sh \
|
||||||
build.sh \
|
build.sh \
|
||||||
repl.sh ca/repl.sh \
|
repl.sh ca/repl.sh \
|
||||||
ca/build.sh \
|
ca/build.sh \
|
||||||
|
|
Loading…
Reference in a new issue