Open symphorien opened 5 years ago
Also fixes #7
$ ./nix-user-chroot nix ./nix-user-chroot nix echo yay
yay
@lethalman are you still interested in maintaining this?
I ported your implementation to rust. This also fixes the missing license of this project: https://github.com/nix-community/nix-user-chroot
Using pivot_root instead of chroot enables the use of user namespaces inside nix-user-chroot: before
After:
The inspiration for using pivot_root is https://lkml.org/lkml/2018/10/15/628
One quirk is that creating a temporary directory, bind mounting everything inside and then pivot_root does not work (for an unknown reason). The bindmounted directories are empty after pivoting. So instead I go the other way around: pivot_root to an empty directory and then I use the mount point for the old root to repopulate the new one. One detail is that I cannot unmount the old root. So I hide it with another. The only directory which is guaranteed to be in the new root is /nix, so I pivot the old root to /nix. This is a bit confusing when reading the code.