Open kubukoz opened 2 years ago
Would be great to have a PR to fix this!
There are a bunch of these: https://github.com/search?q=repo%3ANixOS%2Fnix.dev+%22fetchTarball+%5C%22%22&type=code
Not necessarily an error, but fetchTarball can take an attribute set as an argument:
fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/nixos-14.12.tar.gz";
sha256 = "1jppksrfvbk5ypiqdz4cddxdl8z6zyzdb2srq8fcffr327ld5jj2";
}
Note that when obtaining the hash with nix-prefetch-url the option --unpack is required.
Earlist example in nix.dev that I see using fetchTarball
is here: https://nix.dev/tutorials/first-steps/declarative-shell
@fricklerhandwerk worth changing?
The whole topic of obtaining remote sources is a ball of yarn. None of the obvious alternatives are pretty:
nix-prefetch-url
doesn't use the fetcher cache, so it's extremely inefficient for the most common use case, Nixpkgsnpins
in a guide, but that requires having Nixpkgs (here we take whatever comes with the installation)I'm leaning towards not changing the first encounter, and maybe introducing npins
earlier and more explicitly, fixing nix-prefetch-url
, and finally figuring out native fetching and locking (or ditching it altogether to be replaced with something else).
Currently, all the tutorials on pinning (https://nix.dev/tutorials/towards-reproducibility-pinning-nixpkgs / https://nix.dev/reference/pinning-nixpkgs#ref-pinning-nixpkgs) seem to use
fetchTarball
without passing a sha - the snippets should probably be updated to include that, and provide some hints on where to get the sha.