Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builtins.fetchGit fails with .gitmodules entries that aren't submodules #10739

Open
alyssais opened this issue May 19, 2024 · 2 comments
Open
Labels
bug fetching Networking with the outside (non-Nix) world

Comments

@alyssais
Copy link
Member

Describe the bug

In the situation where a git submodule used to exist, has been moved into the main repo, but not removed from .gitmodules, Nix is unable to fetchGit with submodules. git clone is able to handle this fine, because .gitmodules is not the source of truth for what submodules exist — it's only used as a lookup table for where to fetch unpopulated submodules. I think the right thing for Nix to do here is look through the git tree, and only fill in submodules that are actually submodules, ignoring other .gitmodules entries.

Steps To Reproduce

nix-repl> builtins.fetchGit { url = https://chromium.googlesource.com/chromiumos/platform/crosvm; ref = "release-R124-15823.B"; submodules = true; }
error:
       … while calling the 'fetchGit' builtin
         at «string»:1:1:
            1| builtins.fetchGit { url = https://chromium.googlesource.com/chromiumos/platform/crosvm; ref = "release-R124-15823.B"; submodules = true; }
             | ^

       … while fetching the input 'git+https://chromium.googlesource.com/chromiumos/platform/crosvm?ref=release-R124-15823.B&submodules=1'

       error: '«unknown»/third_party/vmm_vhost' is not a submodule

Expected behavior

Works.

nix-env --version output

nix-env (Nix) 2.22.0

Additional context

Add any other context about the problem here.

Priorities

Add 👍 to issues you find important.

@alyssais alyssais added the bug label May 19, 2024
@roberth roberth added the fetching Networking with the outside (non-Nix) world label May 20, 2024
@roberth roberth added this to the fetch-tree stabilisation milestone May 20, 2024
@fricklerhandwerk
Copy link
Contributor

Triage in Nix maintainers meeting:

  • @Ericson2314: Yes, this is indeed a bug. .gitmodules must not be the source of truth. @roberth and I tested the opposite thing where we kept the submodule and removed the .gitmodules entry.

    Currently, a submodule is always replaced with an empty directory, and a "bind mount" SourceAccessor is used to overlay the missing submodules based on .gitmodules. That is indeed wrong. Instead, every time a submodule (child commit object) is found, we should call some sort of callback to do the right thing, which forces the case to be handled from the proper source of truth.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-05-22-nix-team-meeting-minutes-147/45835/1

RichardWarfield pushed a commit to litxio/solana-nix that referenced this issue Jul 14, 2024
     Fetch the necessary submodules for jito-solana manually and
     reconstruct the source tree.

     upstream issue is NixOS/nix#10739
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fetching Networking with the outside (non-Nix) world
Projects
Status: Defined work
Development

No branches or pull requests

4 participants