Skip to content

Flakes: "follows" in locked input works as if it's in the top level. #5093

@cab404

Description

@cab404

Describe the bug

"follows" on any non-top-level locked input work as if they follow top level flake with the same name.

Steps To Reproduce
Create some test directory with full path FULLPATH and write following files:
a/flake.nix

{
  inputs = {
    c.url = "FULLPATH/c";
  };
  outputs = _: {};
}

b/flake.nix

{
  inputs = {
    d.url = "FULLPATH/d";
  };
  outputs = _: {};
}

c/flake.nix

{
  inputs = {
    d.url = "FULLPATH/d";
    b.url = "FULLPATH/b";
    b.inputs.d.follows = "d";
  };
  outputs = _: {};
}

d/flake.nix

{
  inputs = {};
  outputs = _: {};
}

Then lock c and try locking a.

cd c; nix flake lock
cd a; nix flake lock

Locking a fails with error: input 'c/b/d' follows a non-existent input 'd'
If you remove flake.lock from c, you'll get correct behavior.

Expected behavior
Correctly locked flake, with lockfile in "c" being used for follows value.

nix-env --version output
nix-env (Nix) 2.4pre20210707_02dd6bb

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions