teslamate-org/teslamate

ci: Auto update hashes in nix

Open

#4,156 建立於 2024年8月22日

在 GitHub 查看
 (11 留言) (1 反應) (0 負責人)Elixir (932 fork)batch import
Hacktoberfestenhancementkind:documentation

倉庫指標

Star
 (7,981 star)
PR 合併指標
 (平均合併 5天 19小時) (30 天內合併 41 個 PR)

描述

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.

https://github.com/teslamate-org/teslamate/blob/9b2de5ffa0d0943c9bd89825af681fea14af91df/flake.nix#L27 https://github.com/teslamate-org/teslamate/blob/9b2de5ffa0d0943c9bd89825af681fea14af91df/flake.nix#L35

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 https://github.com/argoproj/argo-workflows/pull/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.

貢獻者指南