Skip to content

Undesired git fetch of path flake inputs that point at git submodules #13324

@mightyiam

Description

@mightyiam

It seems that path inputs that happen to point at git submodules trigger git fetching. And I don't think that's desirable.

$ git clone https://github.com/mightyiam/infra.git repro
$ git checkout --detach 5a46333c95a9238f1e0b376acf196cb2b7b76f2e`

Notice a flake input home-manager that has a url "path:./forks/home-manager".

At that path is a git submodule.

From .gitmodules:

[submodule "forks/home-manager"]
	path = forks/home-manager
	url = ./.

What I expect Nix to do is treat that home-manager input as a local path only.

For example, if that path is empty (pre submodule init) I expect Nix to complain that there is no flake at that path.

Instead, Nix seems to find out that at that path is a git submodule and further find out the url for it and attempt to fetch from there 🤒

$ nix flake show
warning: could not read HEAD ref from repo at '/home/mightyiam/worktrees/repro', using 'master'
error:
       … while fetching the input 'git+file:///home/mightyiam/worktrees/repro?rev=5a46333c95a9238f1e0b376acf196cb2b7b76f2e&submodules=1'

       … while fetching the input 'git+https://github.com/mightyiam/infra.git/?rev=babb4fa136adac892d9b2a300573d914cc2b6baf&submodules=1'

       error: Cannot find Git revision 'babb4fa136adac892d9b2a300573d914cc2b6baf' in ref 'refs/heads/main' of repository 'https://github.com/mightyiam/infra.git/'! Please make sure that the rev exists on the ref you've specified or add allRefs = true; to fetchGit.

Should the attempt to fetch git+https://github.com/mightyiam/infra.git/?rev=babb4fa136adac892d9b2a300573d914cc2b6baf&submodules=1 be considered desired behavior?

Metadata

nix-env (Nix) 2.28.3
nix-env (Nix) 2.29.0

Checklist


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions