Support for sandboxed nix builds
See original GitHub issueI’m trying to get this plugin to work with a nix build, however, having issues with the jvm plugins being able to be ran:
[debug] Executing protoc with [--plugin=protoc-gen-jvm_0=/tmp/protocbridge9859361803622670227, --jvm_0_out=/build/mantis/target/scala-2.13/src_managed/main, --jvm_0_opt=grpc, -I/build/mantis/src/main/protobuf, /build/mantis/src/main/protobuf/extvm/msg.proto] and extraEnv=Vector((SCALAPB_SECONDARY_OUTPUT_DIR,/tmp/protocbridge-secondary9760907634468689002))
/tmp/protocbridge9859361803622670227: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--jvm_0_out: protoc-gen-jvm_0: Plugin failed with status code 1.
[error] java.lang.RuntimeException: protoc returned exit code: 1
I’m able to compile the build fine with sbt compile
and nix-shell
. However, this looks to be a supported usecase.
Additional Info
Using sbt-derivation to bootstrap the sbt dependencies
sbt command being ran:
# Executing command line:
/nix/store/545lbvmxildy1j8ijv2l0xc4flaq4q9a-openjdk-15.0.1-ga/lib/openjdk/bin/java
-Dfile.encoding=UTF-8
-Dsbt.boot.directory=.nix/boot
-Dsbt.global.base=.nix/base
-Dsbt.ivy.home=.nix/ivy
-Dnix=true
-Xms1024m
-Xmx1024m
-Xss4M
-XX:ReservedCodeCacheSize=128m
-Dscala.ext.dirs=.nix/base/java9-rt-ext-n_a_15_0_1_internal
-jar
/nix/store/mja02w4d8y00fbqs8id7rzrv0jcmzpny-sbt-1.4.6/share/sbt/bin/sbt-launch.jar
-debug
compile
command-line command being ran:
running "export PATH=$PATH:/nix/store/yazg2m0y3dm15fcllg4aswppvcy364dl-git-2.29.2/bin:/nix/store/ylp0sjddbrx0m4djv9ljxap204ynla1n-protobuf-3.14.0/bin:/nix/store/545lbvmxildy1j8ijv2l0xc4flaq4q9a-openjdk-15.0.1-ga/bin; JAVA_HOME=/nix/store/fwzqlr3jcg51wm6ds62fi9g2qjd6i58k-openjdk-15.0.1-ga-jre/lib; sbt compile --debug -Dnix=true" to warm up the caches
Even patching the build.sbt
to reference the nixstore path for PB.protocExecutable
...
root.settings(PB.protocExecutable := file("/nix/store/ylp0sjddbrx0m4djv9ljxap204ynla1n-protobuf-3.14.0/bin/protoc"))
Thanks for the initial nix-shell though 😃
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
How to run `nix-build` with sandbox = false? - NixOS Discourse
I have been pulling my hair over this for a long time and I just can't see a way of doing. How do...
Read more >4. Nix-style Local Builds - the Cabal User Guide - Read the Docs
Nix -style local builds combine the best of non-sandboxed and sandboxed Cabal: ... They currently work with all versions of GHC supported by...
Read more >Nix package manager - NixOS Wiki
Sandboxing. When sandbox builds are enabled, Nix will setup an isolated environment for each build process. It is used to remove further hidden...
Read more >Nix packaging, the heretic way - zimbatm
One difficulty when using Nix is that it's possible to hit a purity wall. A dependency is not in nixpkgs (yet), and you...
Read more >nix-build command man page - ManKier
Change the name of the symlink to the output path created from result to outlink. The following common options are supported: --help. Prints...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jonringer , I released a new version of sbt-protoc (1.0.0-RC7-1) which hardcodes
/bin/sh
instead of/usr/bin/env sh
, and also allows overriding the shell used withPROTOCBRIDGE_SHELL
environment variable. Since sandboxed environments do provide/bin/sh
then this variable isn’t necessary for this.In addition, sbt-protoc downloads protoc for you, there’s no need to use nix’s provided protobuf, nor a system property for nix, and so.
coreutils
is needed since protocbridge relies oncat
. Another issue is that the default download directory is in the home directory, so we need to setPROTOC_CACHE
to some other dir. Finally, I had to comment out in build.sbt few things that were causing failures in a way that’s irrelevant for ScalaPB.Here are the files that work for me: matris.nix:
protobuf.patch:
Thanks for the incredibly fast turn around on this. I appreciate it greatly! 😃