Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to `nix-build` again a built store path?

Tags:

nix

nixos

I create my own repository to fetch 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

It reveals a store path of /nix/store/096fpy9qjbz5r14aadjnq9d2md9ql9cg-rust-3191fba. The problem is, I forgot to download it's 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 discovered that nix-build doesn't recalculate the hash and see that the path has been built. So, it ends up not downloading the submodules.

Q: Is it nix bug? How can I "rebuild" or redownloading the repository?

P.S. Actually I create a derivation with fetchgit in it, but it fails because the submodules doesn't being downloaded. So, the above case simplify my problem.

like image 769
Abdillah Avatar asked Jan 05 '17 13:01

Abdillah


1 Answers

Not a bug, this is by design.

Derivations that specify a hash are called fixed-output derivations and they only check if hash matches any existing derivations in store and use that. So your fetchSubmodules change is ignored.

For more discussion see https://github.com/NixOS/nix/issues/969

like image 195
iElectric Avatar answered Sep 23 '22 22:09

iElectric