chipsalliance / playground

chipyard in mill :P
74 stars 34 forks source link

shell.nix: specify sha256 of nixpkgs tarball. #30

Closed yuchangyuan closed 2 years ago

yuchangyuan commented 2 years ago

To avoid re-download nixpkgs tarball each time run nix-shell, and make offline usage possible.

ZenithalHourlyRate commented 2 years ago

https://nixos.org/manual/nix/stable/expressions/builtins.html#builtins-fetchTarball

This said that even without sha256 it could be cached, though the time is short (1 hour).

When I used your branch, nix-shell -vvv still said using cache entry, I doubt i f it supports offline usage.

# zenithal in ~T/playground on git:yuchangyuan-master x [14:03:25]                                            
$ nix-shell -vvv                                                                                                                                                                   
acquiring write lock on '/nix/var/nix/temproots/13571'                                                                                                                             
using cache entry '{"name":"source","type":"tarball","url":"https://github.com/NixOS/nixpkgs/archive/b3adce1542df29dd5a35077a3d42bcc47100e74e.tar.gz"}' -> '{"etag":"\"cf55f2a49b78
c22ada3787a642d56bc0393fd75193a6f9213c658a4a4b6895b8\"","lastModified":1655110150}', '/nix/store/03wa2fbp5bpj6yx0z3np98dcrs84gyrk-source'                                    
yuchangyuan commented 2 years ago

I have a experience that, if sha256 is specified, and correspond /nix/store/XXXX exist(seems XXXX can be computed from sha256, I am not sure), nix will just use /nix/store/XXXX, and just ignore the url. I encounter this many times when I update url for a package but forget update its sha256 field, old source which cached inside /nix/store will be used.

I also try patched shell.nix in an offline environment, and sure it works.