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
Allow nix to update wrong hashes #2785
Comments
I marked this as stale due to inactivity. → More info |
I’d still like this feature (although I must admit that |
https://github.com/Mic92/nix-update looks nice! |
yup, and tools like What I am proposing here is a more fundamental and general solution that works no matter where in your nix files the string literal with the hash is stored, and no matter how many layers of abstractions are between the literal and where it is used. OTOH, maybe this is better implemented via a tool like https://github.com/nvbn/thefuck that parses the error message and then just runs a blunt |
One solution is to treat all external source dependencies as flake inputs. That way they can be updated in a uniform way by running |
Again, that’s a narrow solution to the problem that applies when tracking dependencies (and there, I am personally very happy with https://github.com/nmattia/niv, with featurs like |
I marked this as stale due to inactivity. → More info |
@nomeata https://codeberg.org/kiara/cfg/compare/3e7efd27b05b0fe35ae304b52e1247f7593c37b3...fuck-hash |
Love using nix. But one of the most annoying things about it is updating the various hashes of fixed-output derivations (including fetching tarballs, git checkout, SVN etc.)
What I do (and I believe that is the usual thing to do) is that I update the source (URL, revision etc.), and change a random character in the hash string literal, run
nix-build
, look at the error message, copy’n’paste the actual hash, put it back in the.nix
file, and re-runnix-build
.Assuming I am not the only one that is annoyed by this, I would like to propose the following remidy, in two steps:
nix
adds meta-data to those strings that come directly from string literals in a source file the location (filename, row, column) of that string literal, e.g. by adding fields to thestring
struct inValue.hh
. For calculated strings (results of concatenation etc.) no information is stored.This already allows
nix-build
to provide better error messages: Instead of just printing the expected and actual hash, it can precisely tell the user which has they have to update.nix-build
gets an additional paraeter--update-hash
, and when nix encounters such a hash mismatch, and the expected hash has location data attached, and if some sanity checks pass (the given file exists, is writeable, and the given location is actually a the mentioned string literal), it simply updates the hash and continues building.For even more convenience, we could also let
nix-build
, even without a flag, notice that it is attached to a terminal, and upon a hash mismatch, ask the user “do you want me to update the hash for you [Y/n]?”I know that for specially prepared nix derivation, e.g. those that store the GitHub data in a Json file, there is a separate tool to update these. But that only applies to a fraction of the hashes, and still requires extra steps.
The text was updated successfully, but these errors were encountered: