From 86748d357168ab37a4412d03c1f9ee99951843f5 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 2 Feb 2020 15:46:30 +0100 Subject: [PATCH] Re-read flake after updating flake.lock Otherwise we'll evaluate the flake with the wrong metadata (rev, ...). --- src/libexpr/flake/flake.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc index e3fb02591..39fdc776c 100644 --- a/src/libexpr/flake/flake.cc +++ b/src/libexpr/flake/flake.cc @@ -579,8 +579,13 @@ LockedFlake lockFlake( newLockFile.write(path); - // FIXME: rewriting the lockfile changed the - // top-level repo, so we should re-read it. + // Rewriting the lockfile changed the top-level + // repo, so we should re-read it. + FlakeCache dummyCache; + flake = getFlake(state, topRef, {}, lockFlags.useRegistries, dummyCache); + + if (flake.lockedRef.input->isImmutable()) + throw Error("'%s' did not change after I updated its 'flake.lock' file; is 'flake.lock' under version control?", flake.originalRef); #if 0 // Hack: Make sure that flake.lock is visible to Git, so it ends up in the Nix store.