Skip to content
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

Auto update hashes in nix #4156

Open
brianmay opened this issue Aug 22, 2024 · 1 comment
Open

Auto update hashes in nix #4156

brianmay opened this issue Aug 22, 2024 · 1 comment
Labels
enhancement New feature or request kind:documentation Adds or improves documentation

Comments

@brianmay
Copy link
Collaborator

Purpose of this bug report is to document my current findings on this issue in a public place.

I would like a script that can automatically update the hashes in the flakes.

hash = "sha256-CeGtWKLjZJsoHk+uSAIz8s46XyGJWa3ECm5rSRfqlrc=";

npmDepsHash = "sha256-05AKPyms4WP8MHBqWMup8VXR3a1tv/f/7jT8c6EpWBw=";

Here is a solution for npm: https://sitr.us/2024/03/08/nix-npm-and-dependabot.html/

Mix is the problem, I don't know obtain the new hash without building with fakeHash, and then replacing the hash with the hash in the error.

Google search showed me this project which attempted to solve this problem argoproj/argo-workflows#12520 with the following shell script:

# this is reliant on the vendorHash being on line 195
sed -i '195s/vendorHash = \"\([^\"]*\)\"/vendorHash = ""/g' ./dev/nix/flake.nix
NIX_HASH=$(nix --log-format raw build ./dev/nix 2>&1 | grep  "got: " | awk '{ split($0,a,"got:    "); print a[2] }')
sed -i '195s|vendorHash = \"\([^\"]*\)\"|vendorHash = "'$NIX_HASH'"|g' ./dev/nix/flake.nix
echo "Changed Nix hash to : $NIX_HASH"
rm -rf result

Unfortunately this is broken, it will try to build the project with the old hash, and if the old hash exists, it will be the wrong version.

@JakobLichterfeld JakobLichterfeld added kind:documentation Adds or improves documentation enhancement New feature or request labels Aug 23, 2024
@brianmay
Copy link
Collaborator Author

brianmay commented Oct 9, 2024

I asked about this on the matrix channel https://matrix.to/#/!RRerllqmbATpmbJgCn:nixos.org/$HxXrDb80i36hBG3uY4kE8PaX_G3NsM4bKFInux3Q-Xg?via=nixos.org&via=matrix.org&via=tchncs.de

image

Probably need to find a better forum where the maintainers of the elxir and npm code can see it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request kind:documentation Adds or improves documentation
Projects
None yet
Development

No branches or pull requests

2 participants