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

chore: add script to update vendorSha256 in Nix flake #877

Open
jakubgs opened this issue Nov 8, 2023 · 0 comments
Open

chore: add script to update vendorSha256 in Nix flake #877

jakubgs opened this issue Nov 8, 2023 · 0 comments

Comments

@jakubgs
Copy link
Contributor

jakubgs commented Nov 8, 2023

Background

Currently it is necessary to update manually the vendorSha256 in flake.nix:

go-waku/flake.nix

Lines 31 to 32 in 150ade6

# FIXME: This needs to be manually changed when updating modules.
vendorSha256 = "sha256-4xChSKAkwwrFp5/ZMnhtvsR4drVfw1cLE3YXwVHeW0A=";

Which requires building the node and getting correct SHA256 from the error.
It would be better if we could run a script to do this for us.

Details

I researched this a bit before and started a thread on Nix Discourse:
https://discourse.nixos.org/t/how-should-i-build-a-go-package-from-local-source/19490/11

Which led me to nix-prefetch tool, but it appears to lack support for flakes:

Because when I try to use it nothing happens:

nix-prefetch --option extra-experimental-features flakes \
  '{ sha256 }: (builtins.getFlake (toString ./.)).packages.x86_64-linux.node.go-modules.overrideAttrs (_: { vendorSha256 = sha256; })'

But it is known to work for non-Flake derivations, here's an example in ``:

newvendorSha256="$(NIX_PATH="nixpkgs=https://github.com/nixos/nixpkgs/archive/nixos-unstable.tar.gz" \
  nix-prefetch \
    "{ sha256 }: let p=(import ./packages.nix).${upattr}; in p.go-modules.overrideAttrs (_: { vendorSha256 = sha256; })")"
sed -i "s|${vendorSha256}|${newvendorSha256}|" "${metadata}"

https://github.com/colemickens/nixpkgs-wayland/blob/c9c4a80715557caf57f403038a267f3c20859424/update.sh#L87

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant