enter: better control over copied host envvars
Currently, all host environment variables are copied into the container, except for a hardcoded few that are ignored: https://github.com/89luca89/distrobox/blob/3b9f0e8d3d8bd102e1636a22afffafe00777d30b/distrobox-enter#L435
This is not always the desired behavior, particularly on host distros like NixOS or Guix that break from the FHS and need to set a lot of environment variables to work around the resulting issues:
https://github.com/89luca89/distrobox/issues/1516
Therefore, provide a --no-envvars option to disable the default copying of environment variables, and an --additional-envvars option to copy specific ones.
It was suggested to use env -u distrobox in order to unset specific environment variables:
https://github.com/89luca89/distrobox/issues/656
However, there are usually too many copied environment variables to unset them all individually.
env -i distrobox will unset all environment variables, but that includes PATH and other things needed for distrobox to execute correctly on the host.
Other instances of this feature being requested: https://github.com/89luca89/distrobox/issues/508 https://github.com/89luca89/distrobox/issues/743 https://github.com/89luca89/distrobox/discussions/1173
I thought I should give a specific example of how this is useful, so here goes:
I installed Distrobox for the first time, on Guix. When I tried to run Emacs from a Fedora container, it segfaulted. I spent hours trawling through bug trackers and gdbing the coredump, to no avail.
Then I noticed that git was also broken in the container. This time the error message was easier to search for, and I realised that GIT_EXEC_PATH=/run/current-system/profile/libexec/git-core set by Guix was being copied into the container by distrobox-enter, which was preventing Git from looking under /usr/libexec/git-core. (There were several other such environment variables, too.)
After fixing this, it dawned on me that I was probably seeing the same issue with Emacs. Eventually, after painstakingly unsetting dozens of environment variables, I managed to get it to launch fine.
With this PR, I just have to pass --clean-path --no-envvars --additional-envvars WAYLAND_DISPLAY,XDG_SESSION_TYPE.
Hopefully that gives an idea of why this might be a desirable change.