proot-distro icon indicating copy to clipboard operation
proot-distro copied to clipboard

Add NixOS

Open leap0x7b opened this issue 3 years ago • 4 comments

Closes #215

Supersedes #217

leap0x7b avatar Jun 13 '22 10:06 leap0x7b

This looks good to me, but during the installation step. two errors rise

  1. The nixos rootfs does not have /usr/lib directory which find looks for. it will abort the installation prematurely if the /usr/lib directory wasn't found when finding it which is happened, though this can be skipped by returning exit code to 0 regardless if it was found or not or remove the libgcc hack line and perform it in distro setup step instead in specific distro plugins (this maybe better since it would reduce install time for all distros, newer distros have tigervnc crash fixed and can work without it) https://github.com/termux/proot-distro/blob/2aa9694004787f92fc3f07e5b648f3ee2d47a39e/proot-distro.sh#L372

  2. It also fails during the profile writing step. it's unknown why it fails since the rootfs have /etc script and would normally write or append it either in /etc/profile.d or in /etc/profile, chmod also has true OR statement which forces it to have 0 exit code since it runs the command whether the profile script exists or not and not to terminate the script if chmod fails (as the -e flag is set) https://github.com/termux/proot-distro/blob/2aa9694004787f92fc3f07e5b648f3ee2d47a39e/proot-distro.sh#L363


You should be able to replicate this behavior by downloading rootfs artifacts based on your device's CPU architecture, and the generated distro plugin artifact. copy the plugin in $PREFIX/etc/proot-distro and change the URL to local path using the file:/// URI pointing to your distribution rootfs

ghost avatar Jun 14 '22 12:06 ghost

Before merging, the distro rootfs should have the files unlinked or have a supplementary copies of it from nix directory:

  • /etc/hosts
  • /etc/passwd
  • /etc/gshadow
  • /etc/shadow
  • /etc/resolv.conf
  • /etc/group

Redirection fails which is the reason why it fails during installation as suppose the target directory wasn't found. my previous comment probably also has /etc/profile linked which is the culprit of the install failure even if it was forced return 0 exit code. since the redirection is done outside of proot, it doesn't know that the /nix directory outside exists or not.

Inspect the rootfs and the script of distro_setup function on how files were created during setup See: https://github.com/termux/proot-distro/blob/2aa9694004787f92fc3f07e5b648f3ee2d47a39e/proot-distro.sh#L363 https://github.com/termux/proot-distro/blob/2aa9694004787f92fc3f07e5b648f3ee2d47a39e/proot-distro.sh#L398 https://github.com/termux/proot-distro/blob/2aa9694004787f92fc3f07e5b648f3ee2d47a39e/proot-distro.sh#L406 https://github.com/termux/proot-distro/blob/2aa9694004787f92fc3f07e5b648f3ee2d47a39e/proot-distro.sh#L422 for each corresponding files should be converted into regular files rather than a symlink that distro_setup would have perform redirection

ghost avatar Jun 17 '22 01:06 ghost

Maybe we need to run some of the setup script in proot to make sure it always work on any distro including NixOS

leap0x7b avatar Jun 17 '22 10:06 leap0x7b

Most distributions have FHS compliance and are ready for deployment which proot-distro sticks to its current implementations, non-standard ones like genntoo prefix or nixos have unregistered paths and require additional setup

Probably the script should have checks whether the files from /etc that is going to append is a link and should be appended in the actual paths instead

Additionally, setup script would refer to either the build scripts which is the process of configuring the container image before being packaged that is suitable for proot environment or the distro_setup() plugin hook.

ghost avatar Jun 17 '22 11:06 ghost