Skip to content

Commit 40ae559

Browse files
committed
WIP NOK (re. #1730)
1 parent 7359750 commit 40ae559

File tree

6 files changed

+63
-13
lines changed

6 files changed

+63
-13
lines changed

.bazelignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ site
77
.cache
88
.direnv
99
.eclipse
10+
11+
VENDOR

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
- uses: actions/checkout@v5
7070
- uses: cachix/install-nix-action@v31
7171
# TODO Remove --no-sandbox after https://github.com/enola-dev/enola/issues/1713
72-
- run: nix run --no-sandbox . -- help
72+
- run: nix run . -- help
7373

7474
build:
7575
# https://github.com/orgs/community/discussions/25722

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,6 @@ generated/protoc/java/dev/
8080
generated/classpath
8181
generated/javac-processors/
8282
generated/java-class
83+
84+
# bazel vendor --vendor_dir=
85+
VENDOR

docs/use/index.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,4 @@ or clearing `~/.jbang/cache`, do not currently work for this application due to
8989

9090
## Nix
9191

92-
nix run --no-sandbox github:enola-dev/enola
93-
94-
If this fails after printing _"warning: ignoring the client-specified setting 'sandbox', because it is a restricted setting and you are not a trusted user",_ then you need to add your username to the `trusted-users` list in `/etc/nix/nix.conf` (e.g., `trusted-users = root your-username-here`), and then restart the Nix daemon with `sudo systemctl restart nix-daemon.service`.
95-
96-
PS: See [issue #1713](https://github.com/enola-dev/enola/issues/1713) re. why `--no-sandbox` is still needed.
92+
nix run github:enola-dev/enola

flake.nix

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,46 @@
8787
# $ nix build .#enola
8888
# $ result/bin/enola --help
8989
default = enola;
90+
91+
bazel-vendor-dir = pkgs.stdenv.mkDerivation {
92+
#pname = "bazel-vendor-dir";
93+
#version = gitRev;
94+
name = "bazel-vendor-dir";
95+
96+
nativeBuildInputs = [
97+
pkgs.bazel_8
98+
pkgs.protobuf
99+
pkgs.protoc-gen-grpc-java
100+
pkgs.which
101+
jdk'
102+
];
103+
src = ./.;
104+
buildPhase = ''
105+
runHook preBuild
106+
107+
bash tools/protoc/protoc.bash
108+
mkdir VENDOR
109+
pwd
110+
ls
111+
export HOME=$TMPDIR
112+
bazel vendor --vendor_dir=VENDOR //...
113+
114+
runHook postBuild
115+
'';
116+
installPhase = ''
117+
runHook preInstall
118+
119+
ls VENDOR
120+
mkdir -p $out
121+
cp -LR VENDOR $out
122+
123+
runHook postInstall
124+
'';
125+
outputHashMode = "recursive"; # because bazel vendor creates subdirectories
126+
# outputHash = "sha256-mn5Fj3hEjomN1zIAB1JfSItADiU2kstrGdeCH/wRPt4=";
127+
outputHash = pkgs.lib.fakeHash;
128+
};
129+
90130
enola = pkgs.stdenv.mkDerivation {
91131
pname = "enola";
92132
version = gitRev;
@@ -100,25 +140,34 @@
100140
src = ./.;
101141

102142
buildPhase = ''
143+
runHook preBuild
144+
103145
# class dev.enola.common.Version reads VERSION
104146
echo -n "${gitRev}" >tools/version/VERSION
105147
106-
# See https://github.com/NixOS/nix/issues/14024
107-
bash tools/protoc/protoc.bash
148+
#echo ${bazel-vendor-dir}...
149+
#ls -al ${bazel-vendor-dir}
150+
#cp -R ${bazel-vendor-dir} bazel-vendor
151+
#chmod -R u+w bazel-vendor
152+
#echo bazel-vendor...
153+
#ls -al bazel-vendor
108154
109155
export HOME=$TMPDIR
110-
bazel build //java/dev/enola/cli:enola_deploy.jar
156+
bazel build --nofetch --vendor_dir=${bazel-vendor-dir} //java/dev/enola/cli:enola_deploy.jar
157+
158+
runHook postBuild
111159
'';
112160

113161
installPhase = ''
162+
runHook preInstall
163+
114164
mkdir -p "$out/share/java"
115165
cp bazel-bin/java/dev/enola/cli/enola_deploy.jar "$out/share/java"
116166
makeWrapper ${jdk'}/bin/java $out/bin/enola \
117167
--add-flags "-jar $out/share/java/enola_deploy.jar"
118-
'';
119168
120-
# TODO https://github.com/enola-dev/enola/issues/1730
121-
# outputHash = "sha256-hHa+tqNDxe3+Tl190xPWiNiCq0HWU5qcc52rjo3Ncl0=";
169+
runHook postInstall
170+
'';
122171
};
123172
};
124173

tools/evilurl/test.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ allow_list=("java/dev/enola/common/io/resource/UrlResource.java"
2929

3030
# TODO Also grep for .toURL() invocations, and fail for any (new) ones.
3131

32-
found_files=$(find . -name "*.java" -print0 | xargs -0 grep -lE "(^|[^a-zA-Z0-9_.])java\.net\.URL($|[^a-zA-Z0-9_#}])" | while IFS= read -r file; do
32+
found_files=$(find . -name "*.java" -print0 | grep -Zzv VENDOR/ | xargs -0 grep -lE "(^|[^a-zA-Z0-9_.])java\.net\.URL($|[^a-zA-Z0-9_#}])" | while IFS= read -r file; do
3333
file_name=$(basename "$file")
3434
allow_path="${file//.\//}"
3535

0 commit comments

Comments
 (0)