nixpkgs/pkgs/build-support/build-fhs-userenv/default.nix
Nikolay Amiantov 19c497050e fhs-userenv: refactor and try to chdir to the current directory
runScript now expects a filename instead of a Bash snippet; thus, "exec" should be
omitted.
2015-04-22 17:50:41 +03:00

22 lines
506 B
Nix

{ writeText, writeScriptBin, stdenv, ruby } : { env, runScript } :
let
name = env.pname;
# Sandboxing script
chroot-user = writeScriptBin "chroot-user" ''
#! ${ruby}/bin/ruby
${builtins.readFile ./chroot-user.rb}
'';
init = writeText "init" ''
[ -d "$1" ] && [ -r "$1" ] && cd "$1"
shift
exec "${runScript}" "$@"
'';
in writeScriptBin name ''
#! ${stdenv.shell}
exec ${chroot-user}/bin/chroot-user ${env} bash -l ${init} "$(pwd)" "$@"
''