Skip to content

Commit

Permalink
feat: use vend for vendoring instead of go mod vendor
Browse files Browse the repository at this point in the history
go mod vendor doesn't include the entire source of the vendored
dependencies, which breaks some of our deps that use cgo.

also extracts the "check if at repo root" check that's used in several
scripts into a module arg, for easier reuse.
  • Loading branch information
benluelo committed Jun 26, 2023
1 parent e375c3f commit bd34487
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 31 deletions.
11 changes: 11 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@
];
};

ensureAtRepositoryRoot = ''
# If the current directory contains flake.nix, then we are at the repository root
if [[ -f flake.nix ]]
then
echo "We are at the repository root. Running script..."
else
echo "We are NOT at the repository root. Please cd to the repository root and try again."
exit 1
fi
'';

devnetConfig = {
validatorCount = 4;
ethereum = {
Expand Down
11 changes: 2 additions & 9 deletions tools/generate-rust-sol-bindings/generate-rust-sol-bindings.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ ... }: {
perSystem = { self', pkgs, system, config, inputs', crane, stdenv, ... }:
perSystem = { self', pkgs, system, config, inputs', crane, stdenv, ensureAtRepositoryRoot, ... }:
let
attrs = {
src = crane.lib.cleanCargoSource ./.;
Expand Down Expand Up @@ -59,14 +59,7 @@
name = "generate-rust-sol-bindings";
runtimeInputs = [ rust-sol-bindings ];
text = ''
# If the current directory contains flake.nix, then we are at the repository root
if [[ -f flake.nix ]]
then
echo "We are at the repository root. Starting generation..."
else
echo "We are NOT at the repository root. Please cd to the repository root and try again."
exit 1
fi
${ensureAtRepositoryRoot}
outdir="generated/contracts"
Expand Down
11 changes: 2 additions & 9 deletions tools/rust-proto.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ ... }: {
perSystem = { self', pkgs, proto, crane, system, inputs', config, ... }:
perSystem = { self', pkgs, proto, crane, system, inputs', config, ensureAtRepositoryRoot, ... }:
let
protoc-gen-tonic = crane.lib.buildPackage {
pname = "protoc-gen-tonic";
Expand Down Expand Up @@ -322,14 +322,7 @@
name = "generate-rust-proto";
runtimeInputs = [ rust-proto ];
text = ''
# If the current directory contains flake.nix, then we are at the repository root
if [[ -f flake.nix ]]
then
echo "We are at the repository root. Starting generation..."
else
echo "We are NOT at the repository root. Please cd to the repository root and try again."
exit 1
fi
${ensureAtRepositoryRoot}
outdir="generated/rust"
Expand Down
2 changes: 1 addition & 1 deletion uniond/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ require (
github.com/stretchr/testify v1.8.3
google.golang.org/genproto v0.0.0-20230223222841-637eb2293923
google.golang.org/grpc v1.54.0
google.golang.org/protobuf v1.30.0
gopkg.in/yaml.v2 v2.4.0
)

Expand Down Expand Up @@ -177,7 +178,6 @@ require (
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.110.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.7 // indirect
Expand Down
2 changes: 0 additions & 2 deletions uniond/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,6 @@ github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0Jr
github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw=
github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w=
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
github.com/hussein-aitlahcen/gnark-crypto v0.0.0-20230409222230-5346db050fea h1:4eiyQRMNL9fLFUkFHYoJ10jJKRpHH72lcnrzw8b2JwM=
github.com/hussein-aitlahcen/gnark-crypto v0.0.0-20230409222230-5346db050fea/go.mod h1:Iq/P3HHl0ElSjsg2E1gsMwhAyxnxoKK5nVyZKd+/KhU=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ=
Expand Down
11 changes: 2 additions & 9 deletions uniond/proto.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# - https://github.com/cosmos/cosmos-sdk/blob/bf17fec0e7b83f98be8eba220f1800bd2d7d5011/scripts/protocgen.sh
#
{ ... }: {
perSystem = { pkgs, self', inputs', proto, ibc-go, ... }: {
perSystem = { pkgs, self', inputs', proto, ibc-go, ensureAtRepositoryRoot, ... }: {
packages =
let
grpc-gateway = pkgs.buildGoModule {
Expand Down Expand Up @@ -96,14 +96,7 @@
text = ''
set -eo pipefail
# If the current directory contains flake.nix, then we are at the repository root
if [[ -f flake.nix ]]
then
echo "We are at the repository root. Starting generation..."
else
echo "We are NOT at the repository root. Please cd to the repository root and try again."
exit 1
fi
${ensureAtRepositoryRoot}
cd uniond
Expand Down
32 changes: 31 additions & 1 deletion uniond/uniond.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ ... }: {
perSystem = { pkgs, self', crane, system, ... }: {
perSystem = { pkgs, self', crane, system, ensureAtRepositoryRoot, ... }: {
packages = {
bls-eth =
let
Expand Down Expand Up @@ -71,6 +71,36 @@
Env = [ "SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" ];
};
};

go-vendor =
let
vend = pkgs.buildGoModule {
pname = "vend";
version = "0.0.0";
src = pkgs.fetchFromGitHub {
owner = "nomad-software";
repo = "vend";
rev = "a1ea6c775ac230bb1a1428bb96e4306044aa944b";
sha256 = "sha256-7AdE5qps4OMjaubt9Af6ATaqrV3n73ZuI7zTz7Kgm6w=";
};
vendorSha256 = null;
};
in
pkgs.writeShellApplication {
name = "go-vendor";
runtimeInputs = [ pkgs.go vend ];
text = ''
${ensureAtRepositoryRoot}
echo "vendoring uniond..."
cd uniond
vend
echo "vendoring unionpd..."
cd ../unionpd
vend
'';
};
};

checks = {
Expand Down

0 comments on commit bd34487

Please sign in to comment.