I am using NixOS so nix by default has the sandbox enabled.
For a scala project I am using the mill build tool (which is in nixpkgs). With the following shell.nix file I can run nix-shell --pure --run build
and that works fine:
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = with pkgs; [ scala mill graalvm11-ce gcc ];
shellHook = ''
build () {
mill ulang.assembly
native-image --no-fallback -H:IncludeResources='.*' -H:Log=registerResource: -jar out/ulang/assembly/dest/out.jar ulang.exe
}
'';
}
But if I try to rewrite this as a proper derivation like so
{ pkgs ? import <nixpkgs> {} }:
pkgs.stdenv.mkDerivation {
name = "ulang";
src = pkgs.lib.cleanSourceWith {
src = pkgs.lib.cleanSource ./.;
filter = name: type: let baseName = baseNameOf (toString name); in baseName != "out";
};
buildInputs = with pkgs; [graalvm11-ce gcc mill];
buildPhase = ''
mill ulang.assembly
native-image --no-fallback -H:IncludeResources='.*' -H:Log=registerResource: -jar out/ulang/assembly/dest/out.jar ulang.exe
'';
installPhase = ''
mkdir -p $out/bin
cp ulang.exe $out/bin/ulang
'';
}
and then run nix-build
it fails when executing mill in the sandboxed build env:
these derivations will be built:
/nix/store/db9kd0m8ivm9mfn3xppc15jp0lszahzf-ulang.drv
building '/nix/store/db9kd0m8ivm9mfn3xppc15jp0lszahzf-ulang.drv'...
unpacking sources
unpacking source archive /nix/store/m4088rvsq92jhgn4yizm2lz3m3h731r5-source
source root is source
patching sources
configuring
no configure script, doing nothing
building
mkdir: cannot create directory '/homeless-shelter': Permission denied
builder for '/nix/store/db9kd0m8ivm9mfn3xppc15jp0lszahzf-ulang.drv' failed with exit code 1
error: build of '/nix/store/db9kd0m8ivm9mfn3xppc15jp0lszahzf-ulang.drv' failed
I searched through the github repo of mill but could not find any reference of this homeless-shelter thing.
Does anyone know how to get mill working in the sandboxed build env? Or does anyone know if I can disable the sandbox for just one nix-build
?