forked from lix-project/lix
parent
638c56caed
commit
4d030a8d96
|
@ -366,9 +366,9 @@ Flake getFlake(EvalState & state, const FlakeRef & flakeRef, bool impureIsAllowe
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the `NonFlake` corresponding to a `FlakeRef`.
|
// Get the `NonFlake` corresponding to a `FlakeRef`.
|
||||||
NonFlake getNonFlake(EvalState & state, const FlakeRef & flakeRef, FlakeAlias alias)
|
NonFlake getNonFlake(EvalState & state, const FlakeRef & flakeRef, FlakeAlias alias, bool impureIsAllowed = false)
|
||||||
{
|
{
|
||||||
SourceInfo sourceInfo = fetchFlake(state, flakeRef);
|
SourceInfo sourceInfo = fetchFlake(state, flakeRef, impureIsAllowed);
|
||||||
debug("got non-flake source '%s' with flakeref %s", sourceInfo.storePath, sourceInfo.resolvedRef.to_string());
|
debug("got non-flake source '%s' with flakeref %s", sourceInfo.storePath, sourceInfo.resolvedRef.to_string());
|
||||||
|
|
||||||
FlakeRef resolvedRef = sourceInfo.resolvedRef;
|
FlakeRef resolvedRef = sourceInfo.resolvedRef;
|
||||||
|
@ -449,7 +449,7 @@ ResolvedFlake resolveFlakeFromLockFile(EvalState & state, const FlakeRef & flake
|
||||||
} else {
|
} else {
|
||||||
if (handleLockFile == AllPure || handleLockFile == TopRefUsesRegistries)
|
if (handleLockFile == AllPure || handleLockFile == TopRefUsesRegistries)
|
||||||
throw Error("cannot update non-flake dependency '%s' in pure mode", nonFlakeInfo.first);
|
throw Error("cannot update non-flake dependency '%s' in pure mode", nonFlakeInfo.first);
|
||||||
deps.nonFlakeDeps.push_back(getNonFlake(state, nonFlakeInfo.second, nonFlakeInfo.first));
|
deps.nonFlakeDeps.push_back(getNonFlake(state, nonFlakeInfo.second, nonFlakeInfo.first, allowedToUseRegistries(handleLockFile, false)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,9 @@ registry=$TEST_ROOT/registry.json
|
||||||
flake1Dir=$TEST_ROOT/flake1
|
flake1Dir=$TEST_ROOT/flake1
|
||||||
flake2Dir=$TEST_ROOT/flake2
|
flake2Dir=$TEST_ROOT/flake2
|
||||||
flake3Dir=$TEST_ROOT/flake3
|
flake3Dir=$TEST_ROOT/flake3
|
||||||
|
nonFlakeDir=$TEST_ROOT/nonFlake
|
||||||
|
|
||||||
for repo in $flake1Dir $flake2Dir $flake3Dir; do
|
for repo in $flake1Dir $flake2Dir $flake3Dir $nonFlakeDir; do
|
||||||
rm -rf $repo $repo.tmp
|
rm -rf $repo $repo.tmp
|
||||||
mkdir $repo
|
mkdir $repo
|
||||||
git -C $repo init
|
git -C $repo init
|
||||||
|
@ -81,6 +82,13 @@ EOF
|
||||||
git -C $flake3Dir add flake.nix
|
git -C $flake3Dir add flake.nix
|
||||||
git -C $flake3Dir commit -m 'Initial'
|
git -C $flake3Dir commit -m 'Initial'
|
||||||
|
|
||||||
|
cat > $nonFlakeDir/README.md <<EOF
|
||||||
|
Not much
|
||||||
|
EOF
|
||||||
|
|
||||||
|
git -C $nonFlakeDir add README.md
|
||||||
|
git -C $nonFlakeDir commit -m 'Initial'
|
||||||
|
|
||||||
cat > $registry <<EOF
|
cat > $registry <<EOF
|
||||||
{
|
{
|
||||||
"flakes": {
|
"flakes": {
|
||||||
|
@ -199,3 +207,33 @@ nix build -o $TEST_ROOT/result --flake-registry file://$registry file://$flake2D
|
||||||
nix build -o $TEST_ROOT/result --flake-registry file://$registry file://$flake2Dir:bar --tarball-ttl 0
|
nix build -o $TEST_ROOT/result --flake-registry file://$registry file://$flake2Dir:bar --tarball-ttl 0
|
||||||
mv $flake1Dir.tmp $flake1Dir
|
mv $flake1Dir.tmp $flake1Dir
|
||||||
mv $flake2Dir.tmp $flake2Dir
|
mv $flake2Dir.tmp $flake2Dir
|
||||||
|
|
||||||
|
# Add nonFlakeRequires to flake3.
|
||||||
|
rm $flake3Dir/flake.nix
|
||||||
|
|
||||||
|
cat > $flake3Dir/flake.nix <<EOF
|
||||||
|
{
|
||||||
|
name = "flake3";
|
||||||
|
|
||||||
|
epoch = 2019;
|
||||||
|
|
||||||
|
requires = [ "flake1" "flake2" ];
|
||||||
|
|
||||||
|
nonFlakeRequires = {
|
||||||
|
nonFlake = "$nonFlakeDir";
|
||||||
|
};
|
||||||
|
|
||||||
|
description = "Fnord";
|
||||||
|
|
||||||
|
provides = deps: rec {
|
||||||
|
packages.xyzzy = deps.flake2.provides.packages.bar;
|
||||||
|
packages.sth = deps.flake1.provides.packages.foo;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
git -C $flake3Dir add flake.nix
|
||||||
|
git -C $flake3Dir commit -m 'Add nonFlakeRequires'
|
||||||
|
|
||||||
|
# Check whether `nix build` works with a lockfile which is missing a nonFlakeRequires
|
||||||
|
nix build -o $TEST_ROOT/result --flake-registry $registry $flake3Dir:sth
|
||||||
|
|
Loading…
Reference in a new issue