diff options
author | aszlig <aszlig@redmoonstudios.org> | 2017-10-03 21:32:35 +0200 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2017-10-03 23:41:37 +0200 |
commit | 0bf66bd8d1a1db8c512c66069731bf67a9836a44 (patch) | |
tree | 3d010ba317b2dbe8c4f9d05d18de568ff9bf2f62 /pkgs/games/build-support/build-sandbox/default.nix | |
parent | 2c68ece11b950dc9f078ff843a0ba137c76f7076 (diff) |
pkgs/sandbox: Mount paths from path-like variables
On NixOS the LD_LIBRARY_PATH looks similar to this (depending on the configuration): /run/opengl-driver/lib:/run/opengl-driver-32/lib However, we don't have these paths available within the sandbox, because so far we've only used exportReferencesGraph to gather the runtime dependencies after the build has succeeded. This obviously doesn't take into account runtime dependencies from the system itself. We are now taking care of this by using the Nix store library to query the requisities of all the paths that are contained inside path-like variables (multiple paths delimited by colons) and mount them during sandbox setup. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'pkgs/games/build-support/build-sandbox/default.nix')
-rw-r--r-- | pkgs/games/build-support/build-sandbox/default.nix | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/pkgs/games/build-support/build-sandbox/default.nix b/pkgs/games/build-support/build-sandbox/default.nix index 337456e0..e7243d2c 100644 --- a/pkgs/games/build-support/build-sandbox/default.nix +++ b/pkgs/games/build-support/build-sandbox/default.nix @@ -1,6 +1,6 @@ { stdenv, lib, pkgconfig, nix }: -drv: { extraSandboxPaths ? [], ... }@attrs: +drv: { extraSandboxPaths ? [], runtimePathVariables ? [], ... }@attrs: stdenv.mkDerivation ({ name = "${drv.name}-sandboxed"; @@ -43,11 +43,20 @@ stdenv.mkDerivation ({ in "${result} >> params.c") extraSandboxPaths} echo 'return true; }' >> params.c - cat params.c + + echo 'bool mount_runtime_path_vars(struct query_state *qs) {' >> params.c + + ${lib.concatMapStringsSep "\n" (pathvar: let + escaped = lib.escapeShellArg (lib.escape ["\\" "\""] pathvar); + fun = "mount_from_path_var"; + result = "echo 'if (!${fun}(qs, \"'${escaped}'\")) return false;'"; + in "${result} >> params.c") runtimePathVariables} + + echo 'return true; }' >> params.c ''; nativeBuildInputs = [ pkgconfig ]; buildInputs = [ nix ]; makeFlags = [ "BINDIR=${drv}/bin" ]; -} // removeAttrs attrs [ "extraSandboxPaths" ]) +} // removeAttrs attrs [ "extraSandboxPaths" "runtimePathVariables" ]) |