Skip to content

chore: add ability to include custom protoc-gen-go dependency in nix flake #14728

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

Merged
merged 6 commits into from
Sep 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: ability to add custom protoc-gen-go dependency to nix flake
  • Loading branch information
joobisb committed Sep 19, 2024
commit 5b66a505677629e9a72ec89278aca142ce299d4e
24 changes: 23 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@
# From https://nixos.wiki/wiki/Google_Cloud_SDK
gdk = pkgs.google-cloud-sdk.withExtraComponents ([ pkgs.google-cloud-sdk.components.gke-gcloud-auth-plugin ]);

customProtocGenGo = pkgs.buildGoModule rec {
name = "protoc-gen-go";
owner = "protocolbuffers";
repo = "protobuf-go";
rev = "v1.30.0";
src = pkgs.fetchFromGitHub {
owner = "protocolbuffers";
repo = "protobuf-go";
rev = rev;
# This should be updated whenever rev changes!
# To update, set to "", run nix-shell, insert new hash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does the new hash come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a couple of ways to generate the hash, can use either of them

  1. nix-prefetch-git https://github.com/protocolbuffers/protobuf-go --rev v1.30.0
  2. Run nix-shell with sha256 = ""; this will fail to load the shell and output the required hash in the log as seen in the image, use that
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rather integrate this into scripts/update-flake.sh pls?
The less we make folks think, the more likely they are to do the right thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that would be better, I will do that

sha256 = "sha256-GTZQ40uoi62Im2F4YvlZWiSNNJ4fEAkRojYa0EYz9HU=";
};
subPackages = [ "cmd/protoc-gen-go" ];
vendorHash = null;
proxyVendor = true;
preBuild = ''
export GOPROXY=https://proxy.golang.org,direct
go mod download
'';
};

# The minimal set of packages to build Coder.
devShellPackages = with pkgs; [
# google-chrome is not available on OSX and aarch64 linux
Expand Down Expand Up @@ -80,7 +102,7 @@
playwright-driver.browsers
postgresql_16
protobuf
protoc-gen-go
customProtocGenGo
ripgrep
# This doesn't build on latest nixpkgs (July 10 2024)
(pinnedPkgs.sapling)
Expand Down