Add NixOS
Closes #215
Supersedes #217
This looks good to me, but during the installation step. two errors rise
-
The nixos rootfs does not have
/usr/libdirectory whichfindlooks for. it will abort the installation prematurely if the/usr/libdirectory 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 thelibgcchack 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 -
It also fails during the profile writing step. it's unknown why it fails since the rootfs have
/etcscript and would normally write or append it either in/etc/profile.dor in/etc/profile, chmod also hastrueOR 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-eflag 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
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
Maybe we need to run some of the setup script in proot to make sure it always work on any distro including NixOS
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.