nixpkgs/pkgs/build-support/build-fhs-userenv/default.nix

22 lines
506 B
Nix
Raw Normal View History

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