Skip to content

Commit 119a797

Browse files
committed
WIP NOK (re. #1730)
1 parent 46f0e65 commit 119a797

File tree

7 files changed

+81
-15
lines changed

7 files changed

+81
-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: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,53 @@
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-kkEI1w0CNPYhzx516DAkiu1+enRSYkDA/xe0Mn33zMA=";
135+
};
136+
90137
enola = pkgs.stdenv.mkDerivation {
91138
pname = "enola";
92139
version = gitRev;
@@ -96,29 +143,45 @@
96143
pkgs.cacert
97144
pkgs.makeWrapper
98145
pkgs.which
146+
jdk'
99147
];
100148
src = ./.;
101149

102150
buildPhase = ''
151+
runHook preBuild
152+
103153
# class dev.enola.common.Version reads VERSION
104154
echo -n "${gitRev}" >tools/version/VERSION
105155
106-
# See https://github.com/NixOS/nix/issues/14024
156+
#echo ${bazel-vendor-dir}...
157+
#ls -al ${bazel-vendor-dir}
158+
#cp -R ${bazel-vendor-dir} bazel-vendor
159+
#chmod -R u+w bazel-vendor
160+
#echo bazel-vendor...
161+
#ls -al bazel-vendor
162+
163+
# export HOME=$TMPDIR
164+
#export HOME=$(pwd)/home
165+
export HOME=/build/home
166+
mkdir -p $HOME
167+
tar xfz ${bazel-vendor-dir}
168+
pwd
107169
bash tools/protoc/protoc.bash
170+
bazel build --vendor_dir=VENDOR //java/dev/enola/cli:enola_deploy.jar
108171
109-
export HOME=$TMPDIR
110-
bazel build //java/dev/enola/cli:enola_deploy.jar
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

tools/java_toolchain/BUILD

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
load(
44
"@bazel_tools//tools/jdk:default_java_toolchain.bzl",
5-
"DEFAULT_TOOLCHAIN_CONFIGURATION",
5+
# See https://github.com/bazelbuild/rules_java/issues/325:
6+
"NONPREBUILT_TOOLCHAIN_CONFIGURATION",
67
"default_java_toolchain",
78
)
89
#load("@rules_java//java/toolchains:java_runtime.bzl", "java_runtime")
@@ -16,7 +17,8 @@ load(
1617

1718
default_java_toolchain(
1819
name = "repository_default_java_toolchain",
19-
configuration = DEFAULT_TOOLCHAIN_CONFIGURATION,
20+
# See https://github.com/bazelbuild/rules_java/issues/325:
21+
configuration = NONPREBUILT_TOOLCHAIN_CONFIGURATION,
2022

2123
# INSTEAD of: java_runtime = "@rules_java//toolchains:remotejdk_21",
2224
# OR above's: java_runtime = ":jdk_runtime",

0 commit comments

Comments
 (0)