You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
chrootenv: buildFHSUserEnv doesn't work inside sandbox #31104
buildFHSUserEnv doesn't work inside sandbox. It can sometimes be useful to build, or unpack something in an environment that has a lot of assumptions (say, self-extracting checksummed executable, or build system that expects FHS-compliant paths).
Steps to reproduce
Given /etc/nixos/configuration.nix containing:
nix.useSandbox = true;
Given example.nix:
{ stdenv, buildFHSUserEnv }:
let
buildEnv = buildFHSUserEnv {
name = "example-build-env";
runScript = "echo hello";
targetPkgs = pkgs: [];
};
in
stdenv.mkDerivation {
name = "example";
unpackPhase = ":";
buildPhase = "${buildEnv}/bin/${buildEnv.name}";
installPhase = "ln -s ${buildEnv} $out";
}
$ nix-build -E "with import <nixpkgs> {}; callPackage ./example.nix {}"
these derivations will be built:
/nix/store/dm11jjsk39lh8lhi8l88pzvvw85d5c3h-example.drv
building path(s) ‘/nix/store/mq3nlfsalghxj87v41yc4wvkm8196mzs-example’
unpacking sources
patching sources
configuring
no configure script, doing nothing
building
/nix/store/iwxs4nwk80arwkvqdjqcy74r34wcg3wl-chroot-user:45:in `block in make_fcall': No such file or directory (Errno::ENOENT)
from /nix/store/iwxs4nwk80arwkvqdjqcy74r34wcg3wl-chroot-user:131:in `block in <main>'
from /nix/store/iwxs4nwk80arwkvqdjqcy74r34wcg3wl-chroot-user:128:in `each'
from /nix/store/iwxs4nwk80arwkvqdjqcy74r34wcg3wl-chroot-user:128:in `<main>'
builder for ‘/nix/store/dm11jjsk39lh8lhi8l88pzvvw85d5c3h-example.drv’ failed with exit code 1
@bjornfor Thanks! This looks nice, and no Ruby dependency.
BTW, just commenting out line 45 in chroot-user script (one that raises the exception) solves the issue. Probably makes sense to mount /run and /sys only if available.
Activity
[-]buildFHSUserEnv doesn't work inside [/-][+]buildFHSUserEnv doesn't work inside sandbox[/+]FRidh commentedon Nov 1, 2017
I think at this point you would need to use the
vmtoolsto do this. See e.g.buildRPM.bjornfor commentedon Nov 1, 2017
I have noticed the same. I came up with this simpler FHS environment to run Altera Quartus installer on NixOS with sandbox build:
lukateras commentedon Nov 1, 2017
@bjornfor Thanks! This looks nice, and no Ruby dependency.
BTW, just commenting out line 45 in
chroot-userscript (one that raises the exception) solves the issue. Probably makes sense to mount/runand/sysonly if available.bjornfor commentedon Nov 1, 2017
Yes, +1 for working buildFHSUserEnv in sandboxed build.
[-]buildFHSUserEnv doesn't work inside sandbox[/-][+]chrootenv: buildFHSUserEnv doesn't work inside sandbox[/+]