1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 22:33:57 +02:00

Lockfile handling in resolveFlake is fixed

This commit is contained in:
Nick Van den Broeck 2019-05-14 11:34:45 +02:00
parent 98f20dee41
commit ef6ae61503
7 changed files with 149 additions and 85 deletions

View file

@ -1,20 +0,0 @@
with import <nix/config.nix>;
rec {
inherit shell;
path = coreutils;
system = "x86_64-linux";
shared = builtins.getEnv "_NIX_TEST_SHARED";
mkDerivation = args:
derivation ({
inherit system;
builder = shell;
args = ["-e" args.builder or (builtins.toFile "builder.sh" "if [ -e .attrs.sh ]; then source .attrs.sh; fi; eval \"$buildCommand\"")];
PATH = path;
} // removeAttrs args ["builder" "meta"])
// { meta = args.meta or {}; };
}

View file

@ -118,7 +118,7 @@ nix build -o $TEST_ROOT/result --flake-registry $registry flake1:
[[ -e $TEST_ROOT/result/hello ]]
# Building a flake with an unlocked dependency should fail in pure mode.
(! nix build -o $TEST_ROOT/result --flake-registry $registry flake2:bar)
(! nix eval "(builtins.getFlake "$flake2Dir")")
# But should succeed in impure mode.
nix build -o $TEST_ROOT/result --flake-registry $registry flake2:bar --impure
@ -129,8 +129,8 @@ nix build -o $TEST_ROOT/result --flake-registry $registry $flake2Dir:bar
git -C $flake2Dir commit flake.lock -m 'Add flake.lock'
# Rerunning the build should not change the lockfile.
#nix build -o $TEST_ROOT/result --flake-registry $registry $flake2:bar
#[[ -z $(git -C $flake2 diff) ]]
nix build -o $TEST_ROOT/result --flake-registry $registry $flake2Dir:bar
[[ -z $(git -C $flake2Dir diff master) ]]
# Now we should be able to build the flake in pure mode.
nix build -o $TEST_ROOT/result --flake-registry $registry flake2:bar
@ -140,3 +140,32 @@ nix build -o $TEST_ROOT/result file://$flake2Dir:bar
# Test whether indirect dependencies work.
nix build -o $TEST_ROOT/result --flake-registry $registry $flake3Dir:xyzzy
# Add dependency to flake3
rm $flake3Dir/flake.nix
cat > $flake3Dir/flake.nix <<EOF
{
name = "flake3";
epoch = 2019;
requires = [ "flake1" "flake2" ];
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 'Update flake.nix'
# Check whether `nix build` works with an incomplete lockfile
nix build -o $TEST_ROOT/result --flake-registry $registry $flake3Dir:sth
# Check whether it saved the lockfile
[[ ! (-z $(git -C $flake3Dir diff master)) ]]