Skip to content

sub-flake breaks when new input is added to parent flake #12703

Open
@adrian-gierakowski

Description

@adrian-gierakowski

Describe the bug

In a repo setup as follows:

.
├── flake.lock
├── flake.nix
└── sub-flake
    ├── flake.lock
    └── flake.nix

where sub-flake/flake.nix refers to top level flake with:

inputs = {
    parent.url = ./..;
  };

when new input is added to top level flake the sub-flake breaks (fails to evaluate)

Steps To Reproduce

  1. start with a repo structure as shown in this commit
  2. make changes as shown in this commit
  3. run:
cd sub-flake
nix eval .#lib.one

which should print the following error:

error:
       … in the left operand of the update (//) operator
         at «nix-internal»/call-flake.nix:77:9:
           76|         # This is shadowed in the next //
           77|         // sourceInfo
             |         ^
           78|         // {

       … from call site
         at «nix-internal»/call-flake.nix:68:17:
           67|
           68|       outputs = flake.outputs (inputs // { self = result; });
             |                 ^
           69|

       error: function 'outputs' called without required argument 'nixpkgs-lib-2'
       at /nix/store/k84vy37d2qlmagax150drp642klmlgc4-source/flake.nix:10:5:
            9|   outputs =
           10|     { nixpkgs-lib, nixpkgs-lib-2, ... }:
             |     ^
           11|     {

This can be fixed by updating sub-flake/flake.lock by running the following from sub-flake dir:

nix flake update parent

as seen in this commit

Expected behavior

The sub-flake should not need to be updated since all necessary details are already present in the parents flake, so it should simply read the info from there.

Metadata

Additional context

  • Possible solution strategy: Reuse input lock files #7730
    • a simpler, small scope solution may also be possible instead (but wouldn't improve laziness in the remote input case)

Checklist


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfetchingNetworking with the outside (non-Nix) world, input lockingflakes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions