-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
nix-prefetch: init at 0.1.0 #53878
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
nix-prefetch: init at 0.1.0 #53878
Conversation
How does this compare to #53436 ? |
@Mic92 The universal prefetch of #53436 is focused on providing a command line interface for all available fetchers within Nixpkgs, while my prefetch will just use the source as it is defined, i.e. can remain ignorant about what specific fetcher is being used. They both have the same goal, to predetermine the hash of a source, but they have different interfaces that serve different use cases better. The TOFU use case should be easier with my prefetcher, because you just point to the package or its source and it will report the correct hash, instead of having to duplicate the arguments given to the fetcher on the command line. For example: The universal prefetcher: My prefetcher: However the universal prefetcher is a better fit when all this information is already available to you in your update script, then the new hash can already be determined, while my prefetcher would require the update script to first update the package with the new version information in order for it to determine the correct new hashes for the sources. |
@Mic92 I have an idea on how to merge the two prefetchers to get the best of both approaches, so I will be closing the PR in the meantime. |
@Mic92 I reopened it with a version that is nothing alike the one I originally opened it with. Here are some of its features: https://github.com/msteen/nix-prefetch#features @bhipple It does also support any package defining a @danbst It got completions including autcomplete for the fetcher arguments for both @7c6f434c I think I have now covered all fetchers I could find with |
The packaging seems nice. The script logic: so, a version bump requires additionally breaking the hash for prefetching to work? (for example, for fetchFromGitHub)? |
You mean whether you still need to modify the hash (e.g. |
You mean whether you still need to modify the hash (e.g. `sha256`) attribute passed to `fetchFromGitHub`? If so, no that's not needed. It will default to a probably wrong hash (zeroed hash):
I looked at that, and I am not sure what you mean about default — I mean the case when I already have a package and want to upgrade it, so there is some sha256, and it has been fetched.
|
It will just ignore the existing A package with verbose output:
It is redownloading it, because outside the exceptions I just gave, its normally impossible for me to know whether a hash is correct except from recalculating it. |
Then I don't understand what it checks w.r.t. the source being already in store
|
I could try and break it in more pieces and comment it some more, but what it does is check if there is something in the nix store that already refers to the source derivation that is about to be realized (i.e. prefetched). If there exist such derivations, and the outputs of those derivations actually exist in the nix store (this does not have to be the case), then we don't have any reason to refetch it. However it could still be the product of building your package with an updated version but outdated hash (so it would have used the old sources), so I check if there is a root to it (outside from generally temporary result roots), then I can be very certain there is no need to refetch the source. It would have been a really straightforward check it were not for: NixOS/nix#2631 Its usefulness has gone down now that I found out that there is no way to determine the correctness of a hash or whether it is outdated, other than this approximation. Thinking about it again, I think its better to only do this check via a flag, rather than by default. So I would be removing |
@7c6f434c I have added more thorough comments on that piece of script. This is how I updated the Nixpkgs definition just now: |
Oh. Nice! Thank you very much for the additions. Now the «model of world» is indeed clear. I don't know if it is a good idea to mention somewhere (maybe in README?) that what it does is uses n overlay to wrap various commands to ignore the insecure flags. |
Motivation for this change
I wanted better tooling to get the hash of the sources of a package to help with update scripts, e.g. I am using this for my not yet published update script for the OpenRA mods. The existing
nix-prefetch-url
was sufficient for this use case and I wanted to prevent the need for having to add a dummy hash yourself at first use every time.Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)