Skip to content

Commit 7a4dfc0

Browse files
committed
chore: Test 'bazel vendor' Nix outputHash stability (re. #1875)
1 parent 34106f0 commit 7a4dfc0

File tree

3 files changed

+52
-6
lines changed

3 files changed

+52
-6
lines changed

.bazelignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ site
44

55
.be
66
.bazelbsp
7+
.built
78
.cache
89
.direnv
910
.eclipse

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,13 @@ web/web-out/
4545
# Maven
4646
java/.mvn/wrapper/maven-wrapper.jar
4747
java/target
48-
.built/.m2
4948

5049
# https://jbang.dev
5150
.jbang/
5251

5352
tools/version/VERSION
5453

55-
# LinkML
54+
# Miscellaneous generated/output varia (incl. LinkML, .m2, HOME, VENDOR, etc.)
5655
.built
5756

5857
# https://github.com/VirtusLab/bazel-steward/issues/424

flake.nix

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,49 @@
8787
# $ nix build .#enola
8888
# $ result/bin/enola --help
8989
default = enola;
90+
# Testing https://github.com/enola-dev/enola/issues/1875 ...
91+
bazel-vendor-dir = pkgs.stdenv.mkDerivation {
92+
pname = "bazel-vendor-dir";
93+
version = gitRev;
94+
95+
nativeBuildInputs = [
96+
pkgs.bazel_8
97+
pkgs.protobuf
98+
pkgs.protoc-gen-grpc-java
99+
pkgs.which
100+
jdk'
101+
];
102+
src = ./.;
103+
buildPhase = ''
104+
runHook preBuild
105+
106+
bash tools/protoc/protoc.bash
107+
108+
# https://github.com/enola-dev/enola/issues/1876
109+
export HOME=.built/HOME
110+
mkdir -p $HOME
111+
112+
export VENDOR=.built/VENDOR
113+
mkdir -p $VENDOR
114+
bazel vendor --vendor_dir=$VENDOR //...
115+
116+
runHook postBuild
117+
'';
118+
installPhase = ''
119+
runHook preInstall
120+
121+
tar czvf $out \
122+
--sort=name \
123+
--mtime='UTC 2080-02-01' \
124+
--owner=0 \
125+
--group=0 \
126+
--numeric-owner $VENDOR
127+
128+
runHook postInstall
129+
'';
130+
# outputHash = pkgs.lib.fakeHash;
131+
outputHash = "sha256-ExeaXCtvUJa27pDQPixoGQH1Vu1Nh8NzciAqPOJJwRE=";
132+
};
90133
enola = pkgs.stdenv.mkDerivation {
91134
pname = "enola";
92135
version = gitRev;
@@ -100,13 +143,19 @@
100143
src = ./.;
101144

102145
buildPhase = ''
146+
# This currently only serves to force a dependency to above
147+
ls -al ${bazel-vendor-dir}
148+
103149
# class dev.enola.common.Version reads VERSION
104150
echo -n "${gitRev}" >tools/version/VERSION
105151
106152
# See https://github.com/NixOS/nix/issues/14024
107153
bash tools/protoc/protoc.bash
108154
109-
export HOME=$TMPDIR
155+
# https://github.com/enola-dev/enola/issues/1876
156+
export HOME=.built/HOME
157+
mkdir -p $HOME
158+
110159
bazel build //java/dev/enola/cli:enola_deploy.jar
111160
'';
112161

@@ -116,9 +165,6 @@
116165
makeWrapper ${jdk'}/bin/java $out/bin/enola \
117166
--add-flags "-jar $out/share/java/enola_deploy.jar"
118167
'';
119-
120-
# TODO https://github.com/enola-dev/enola/issues/1730
121-
# outputHash = "sha256-hHa+tqNDxe3+Tl190xPWiNiCq0HWU5qcc52rjo3Ncl0=";
122168
};
123169
};
124170

0 commit comments

Comments
 (0)