diff --git a/modules/programs/make-sandboxed.nix b/modules/programs/make-sandboxed.nix index 200a78893..c749a0fb0 100644 --- a/modules/programs/make-sandboxed.nix +++ b/modules/programs/make-sandboxed.nix @@ -98,14 +98,17 @@ let else mv "$_dir/$_name" "$_dir/.sandboxed/" fi + makeShellWrapper ${sanebox'} "$_dir/$_name" --suffix PATH : /run/current-system/sw/libexec/${sanebox.pname} \ + --inherit-argv0 \ ${lib.escapeShellArgs (lib.flatten (builtins.map (f: [ "--add-flags" f ]) extraSandboxArgs))} \ --add-flags "$_dir/.sandboxed/$_name" - # `exec`ing a script with an interpreter will smash $0. instead, source it to preserve $0: - # - + if [ -n "${sanebox.interpreter or ""}" ]; then + # `exec`ing a script with an interpreter will smash $0. instead, source it to preserve $0: + # - substituteInPlace "$_dir/$_name" \ - --replace-fail 'exec ' 'source ' + --replace-fail 'exec -a "$0" ' 'source ' fi }