How can `nix-build` create the repository path again?

I create my own repository to get some git source.

# packages.nix
with (import <nixpkgs> {});

rec {
  rustcSource = fetchgit {
    url = https://github.com/rust-lang/rust;
    rev = "3191fbae9da539442351f883bdabcad0d72efcb6";
    sha256 = "0w1l14kz9kxyj5dw3w9xxk1fzww5xqs3sf8saay0mh7nkmvrdb59";
  };
}

Then I build rustcSource,

sudo nix-env -f package.nix -A rustcSource

Shows the storage path /nix/store/096fpy9qjbz5r14aadjnq9d2md9ql9cg-rust-3191fba. The problem is that I forgot to load its submodules, so I change my expression to include submodules,

with (import <nixpkgs> {});

rec {
  rustcSource = fetchgit {
    url = https://github.com/rust-lang/rust;
    rev = "3191fbae9da539442351f883bdabcad0d72efcb6";
    sha256 = "0w1l14kz9kxyj5dw3w9xxk1fzww5xqs3sf8saay0mh7nkmvrdb59";
    leaveDotGit = true;
    fetchSubmodules = true;
  };
}

But I found that I nix-builddid not recalculate the hash and did not see that the path was built. Thus, it does not load submodules.

Q: Is this a nix error? How can I rebuild or reload the repository?

PS Actually, I create output with fetchgit in it, but it fails because the submodules are not loading. So the above case simplifies my problem.

+4
source share
3

, .

, , , . fetchSubmodules .

. https://github.com/NixOS/nix/issues/969

+3

, , nix.

(, , ), nix, nix . (, ) , .

+2

Removing the submodules will result in a packet with a different hash. The easiest way to fix this is to change the hash to an invalid value and rebuild the package. The error message will contain the correct hash. Use it and rebuild.

+1
source

Source: https://habr.com/ru/post/1665881/


All Articles