nixpkgs/pkgs/build-support/build-fhsenv-bubblewrap
benaryorg 9bc6d23111
buildFHSEnvBubblewrap: extraPreBwrapCmds after variable initialisation
Prior to this commit it was not possible to modify e.g. the list of ignored directories at all, however given that `buildFHSEnvBubblewrap` effectively uses a sandboxing tool (*bwrap*) I feel like this is a missed opportunity.
The code in nixpkgs already covers all the knobs that are required to get *Nix* itself to run inside bubblewrap, so why not allow users to make that additional modification?
While additional `ro_mounts` and such can be *added* to the bubblewrap invocation, the already mounted directories cannot be removed, and even if shadowed by e.g. a tmpfs mount, this would still allow something inside the sandbox to potentially unmount the tmpfs and access the data.

So what this change does is moving the snippet where custom code can be injected down by four lines so that users can actually modify those variables e.g. using `ignored+=( /home /srv /mnt /boot )`.
The only cases in which this would break is:

- someone using those variable names in `extraPreBwrapCmds` already and relying on them being overwritten; I would consider that chance slim, and the fix would be easy enough
- someone using a construct like `false && \` to disable the `ignored` initialisation and effectively working around this limitation; again the chances are slim (even though I know I'd be affected), and the fix would be easy enough (as this change makes the workaround needless anyway so it's an improvement)

Signed-off-by: benaryorg <binary@benary.org>
2024-09-25 09:32:41 +00:00
..
buildFHSEnv.nix treewide: replace stdenv.is with stdenv.hostPlatform.is 2024-09-25 00:04:37 +03:00
default.nix buildFHSEnvBubblewrap: extraPreBwrapCmds after variable initialisation 2024-09-25 09:32:41 +00:00