mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 23:43:30 +00:00
19c497050e
runScript now expects a filename instead of a Bash snippet; thus, "exec" should be omitted.
22 lines
506 B
Nix
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)" "$@"
|
|
''
|