Skip to content

Commit 4191ae6

Browse files
committed
WIP NOK (re. #1730)
1 parent 558e721 commit 4191ae6

File tree

8 files changed

+68
-19
lines changed

8 files changed

+68
-19
lines changed

.bazelignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ site
88
.cache
99
.direnv
1010
.eclipse
11+
12+
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
@@ -79,3 +79,6 @@ generated/protoc/java/dev/
7979
generated/classpath
8080
generated/javac-processors/
8181
generated/java-class
82+
83+
# bazel vendor --vendor_dir=
84+
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.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,52 @@
9292
# $ nix build .#enola
9393
# $ result/bin/enola --help
9494
default = enola;
95+
96+
bazel-vendor-dir = pkgs.stdenv.mkDerivation {
97+
#pname = "bazel-vendor-dir";
98+
#version = gitRev;
99+
name = "bazel-vendor-dir";
100+
101+
nativeBuildInputs = [
102+
pkgs.protobuf
103+
pkgs.protoc-gen-grpc-java
104+
pkgs.which
105+
jdk'
106+
];
107+
src = ./.;
108+
buildPhase = ''
109+
runHook preBuild
110+
111+
bash tools/protoc/protoc.bash
112+
mkdir VENDOR
113+
pwd
114+
ls
115+
# export HOME=$TMPDIR
116+
# export HOME=$(pwd)/home
117+
export HOME=/build/home
118+
mkdir -p $HOME
119+
pwd
120+
ls
121+
bazel vendor --vendor_dir=VENDOR //...
122+
123+
runHook postBuild
124+
'';
125+
installPhase = ''
126+
runHook preInstall
127+
128+
tar czvf $out \
129+
--sort=name \
130+
--mtime='UTC 2080-02-01' \
131+
--owner=0 \
132+
--group=0 \
133+
--numeric-owner VENDOR
134+
135+
runHook postInstall
136+
'';
137+
# outputHash = pkgs.lib.fakeHash;
138+
outputHash = "sha256-kpDyYdYTlC179qHOusvTncRXAGV7549GGoR1y4b8okA=";
139+
};
140+
95141
enola = pkgs.stdenv.mkDerivation {
96142
pname = "enola";
97143
version = gitRev;
@@ -101,6 +147,7 @@
101147
pkgs.cacert
102148
pkgs.makeWrapper
103149
pkgs.which
150+
jdk'
104151
];
105152
src = ./.;
106153

@@ -110,14 +157,13 @@
110157
# class dev.enola.common.Version reads VERSION
111158
echo -n "${gitRev}" >tools/version/VERSION
112159
113-
# See https://github.com/NixOS/nix/issues/14024
114-
bash tools/protoc/protoc.bash
115-
116160
# https://github.com/enola-dev/enola/issues/1876
117161
export HOME="$PWD/.built/HOME"
118162
mkdir -p "$HOME"
119163
120-
bazel build //java/dev/enola/cli:enola_deploy.jar
164+
tar xfz ${bazel-vendor-dir}
165+
bash tools/protoc/protoc.bash
166+
bazel build --vendor_dir=VENDOR //java/dev/enola/cli:enola_deploy.jar
121167
122168
runHook postBuild
123169
'';

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)