1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-08 11:03:54 +02:00

Make flake input fetching lazy

As long as the flake input is locked, it is now only fetched when it
is evaluated (e.g. "nixpkgs" is fetched when
"inputs.nixpkgs.<something>" is evaluated).

This required adding an "id" attribute to the members of "inputs" in
lockfiles, e.g.

  "inputs": {
    "nixpkgs/release-19.03": {
      "id": "nixpkgs",
      "inputs": {},
      "narHash": "sha256-eYtxncIMFVmOHaHBtTdPGcs/AnJqKqA6tHCm0UmPYQU=",
      "nonFlakeInputs": {},
      "uri": "github:edolstra/nixpkgs/e9d5882bb861dc48f8d46960e7c820efdbe8f9c1"
    }
  }

because the flake ID needs to be known beforehand to construct the
"inputs" attrset.

Fixes #2913.
This commit is contained in:
Eelco Dolstra 2019-06-04 19:10:35 +02:00
parent c7c562416c
commit 6dbd5c26e6
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
6 changed files with 272 additions and 187 deletions

View file

@ -191,6 +191,8 @@ nix build -o $TEST_ROOT/result --flake-registry $registry $flake3Dir:sth
# Check whether it saved the lockfile
[[ ! (-z $(git -C $flake3Dir diff master)) ]]
git -C $flake3Dir commit -m 'Add lockfile'
# Unsupported epochs should be an error.
sed -i $flake3Dir/flake.nix -e s/201906/201909/
nix build -o $TEST_ROOT/result --flake-registry $registry $flake3Dir:sth 2>&1 | grep 'unsupported epoch'
@ -241,3 +243,12 @@ git -C $flake3Dir commit -m 'Add nonFlakeInputs'
# Check whether `nix build` works with a lockfile which is missing a nonFlakeInputs
nix build -o $TEST_ROOT/result --flake-registry $registry $flake3Dir:sth
# Check whether flake input fetching is lazy: flake3:sth does not
# depend on flake2, so this shouldn't fail.
rm -rf $TEST_HOME/.cache
clearStore
mv $flake2Dir $flake2Dir.tmp
nix build -o $TEST_ROOT/result --flake-registry $registry flake3:sth
(! nix build -o $TEST_ROOT/result --flake-registry $registry flake3:xyzzy)
mv $flake2Dir.tmp $flake2Dir