Skip to content

Commit b85a298

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

File tree

6 files changed

+79
-15
lines changed

6 files changed

+79
-15
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: 71 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,54 @@
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+
# export HOME=$(pwd)/home
113+
export HOME=/build/home
114+
mkdir -p $HOME
115+
pwd
116+
ls
117+
bazel vendor --vendor_dir=VENDOR //...
118+
119+
runHook postBuild
120+
'';
121+
installPhase = ''
122+
runHook preInstall
123+
124+
tar czvf $out \
125+
--sort=name \
126+
--mtime='UTC 2080-02-01' \
127+
--owner=0 \
128+
--group=0 \
129+
--numeric-owner VENDOR
130+
131+
runHook postInstall
132+
'';
133+
# outputHash = pkgs.lib.fakeHash;
134+
# outputHash = "sha256-ay1aRIY1nJemeRon4SFMd23Rs/+4kCiVio4aeHDHvMg=";
135+
outputHash = "sha256-PPJlh/i+DOTfo9NMIcj9CB7pQUN2ygqzO2TApHrWMZw=";
136+
};
137+
90138
enola = pkgs.stdenv.mkDerivation {
91139
pname = "enola";
92140
version = gitRev;
@@ -96,29 +144,44 @@
96144
pkgs.cacert
97145
pkgs.makeWrapper
98146
pkgs.which
147+
jdk'
99148
];
100149
src = ./.;
101150

102151
buildPhase = ''
152+
runHook preBuild
153+
103154
# class dev.enola.common.Version reads VERSION
104155
echo -n "${gitRev}" >tools/version/VERSION
105156
106-
# See https://github.com/NixOS/nix/issues/14024
107-
bash tools/protoc/protoc.bash
108-
109-
export HOME=$TMPDIR
110-
bazel build //java/dev/enola/cli:enola_deploy.jar
157+
#echo ${bazel-vendor-dir}...
158+
#ls -al ${bazel-vendor-dir}
159+
#cp -R ${bazel-vendor-dir} bazel-vendor
160+
#chmod -R u+w bazel-vendor
161+
#echo bazel-vendor...
162+
#ls -al bazel-vendor
163+
164+
# export HOME=$TMPDIR
165+
#export HOME=$(pwd)/home
166+
export HOME=/build/home
167+
mkdir -p $HOME
168+
tar xfz ${bazel-vendor-dir}
169+
pwd
170+
bazel build --nofetch --vendor_dir=VENDOR //java/dev/enola/cli:enola_deploy.jar
171+
172+
runHook postBuild
111173
'';
112174

113175
installPhase = ''
176+
runHook preInstall
177+
114178
mkdir -p "$out/share/java"
115179
cp bazel-bin/java/dev/enola/cli/enola_deploy.jar "$out/share/java"
116180
makeWrapper ${jdk'}/bin/java $out/bin/enola \
117181
--add-flags "-jar $out/share/java/enola_deploy.jar"
118-
'';
119182
120-
# TODO https://github.com/enola-dev/enola/issues/1730
121-
# outputHash = "sha256-hHa+tqNDxe3+Tl190xPWiNiCq0HWU5qcc52rjo3Ncl0=";
183+
runHook postInstall
184+
'';
122185
};
123186
};
124187

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)