Open lucasew opened 2 years ago
I installed proot
and guided nix-portable
to use local git
and proot
. Got same error as you.
Same on OnePlus 9 pro with 5.4.243 kernel.
Same error on the S24 Ultra trying to unzip zstd
. The code in that area is:
for bin in $busyBins; do
[ ! -e "$dir/busybox/bin/$bin" ] && ln -s busybox "$dir/busybox/bin/$bin"
done
export PATH="$dir/busybox/bin"
# install other binaries
unzip -qqoj "$self" nix/store/19p4fzsi2cfplknv2mpz4q59jl0sdqab-zstd/bin/zstd -d $dir/bin
chmod +wx $dir/bin/zstd;
unzip -qqoj "$self" nix/store/qim5npfpw89nzzq1iwmr8zhbiilar2n7-proot/bin/proot -d $dir/bin
chmod +wx $dir/bin/proot;
unzip -qqoj "$self" nix/store/c9ji7k8kmdpfj2mnh1rjpdg7wpbdxs2b-bwrap/bin/bwrap -d $dir/bin
chmod +wx $dir/bin/bwrap;
unzip -qqoj "$self" nix/store/shc7yym58533x9xl3d0ppci7nhzi9ri3-nix/bin/nix -d $dir/bin
chmod +wx $dir/bin/nix;
# install ssl cert bundle
unzip -poj "$self" nix/store/ydsac02yjmww0xgs3qdxislmky4q43l1-cacerts | $dir/bin/zstd -d > $dir/ca-bundle.crt
recreate_nix_conf
fi
Could we skip this extraction of zstd
? Termux has its own zstd
inside the stable repo and trying to run binaries inside the Termux native environment would fail if they weren't compiled for the bionic
c compiler, as I understand it.
Since the error is always with unzip, could the Termux version be missing a compilation option? Here's the results of unzip -version
on Termux:
UnZip 6.00 of 20 April 2009, by Info-ZIP. Maintained by C. Spieler. Send
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.
Latest sources and executables are at ftp://ftp.info-zip.org/pub/infozip/ ;
see ftp://ftp.info-zip.org/pub/infozip/UnZip.html for other sites.
Compiled with gcc Android (8481493, based on r416183c2) Clang 12.0.9 (https://android.googlesource.com/toolchain/llvm-project c935d99d7cf2016289302412d708641d52d2f7ee) for Unix (Linux ELF) on Aug 9 2022.
UnZip special compilation options:
ACORN_FTYPE_NFS
COPYRIGHT_CLEAN (PKZIP 0.9x unreducing method not supported)
SET_DIR_ATTRIB
SYMLINKS (symbolic links supported, if RTL and file system permit)
TIMESTAMP
UNIXBACKUP
USE_EF_UT_TIME
USE_UNSHRINK (PKZIP/Zip 1.x unshrinking method supported)
USE_DEFLATE64 (PKZIP 4.x Deflate64(tm) supported)
UNICODE_SUPPORT [wide-chars, char coding: UTF-8] (handle UTF-8 paths)
LARGE_FILE_SUPPORT (large files over 2 GiB supported)
ZIP64_SUPPORT (archives using Zip64 for large files supported)
USE_BZIP2 (PKZIP 4.6+, using bzip2 lib version 1.0.8, 13-Jul-2019)
VMS_TEXT_CONV
WILD_STOP_AT_DIR
[decryption, version 2.11 of 05 Jan 2007]
UnZip and ZipInfo environment options:
UNZIP: [none]
UNZIPOPT: [none]
ZIPINFO: [none]
ZIPINFOOPT: [none]
Ahhh I didn't read it correctly.
This part is unpacking a TON of tools including unzip.
for bin in $busyBins; do
[ ! -e "$dir/busybox/bin/$bin" ] && ln -s busybox "$dir/busybox/bin/$bin"
done
Then this line is making the next lines use the recently extracted binaries instead of the system ones:
export PATH="$dir/busybox/bin"
And that fails because it's trying to run unzip
that hasn't been compiled for bionic
in the native Termux environment. >.<
I moved the export PATH="$dir/busybox/bin"
line to the bottom of the function just above recreate_nix_conf
and was able to get a new error message (I later found out I needed to remove the line exporting PATH altogether from that area):
warning [/data/data/com.termux/files/home/nix-portable]: 2 extra bytes at beginning or within zipfile
(attempting to process anyways)
This is an error some people have used 7zip to get around in other situations, so I installed p7zip
and replaced all the unzip
commands with 7za
.
Line 28115:
for bin in $busyBins; do
[ ! -e "$dir/busybox/bin/$bin" ] && ln -s busybox "$dir/busybox/bin/$bin"
done
- export PATH="$dir/busybox/bin"
# install other binaries
- unzip -qqoj "$self" nix/store/19p4fzsi2cfplknv2mpz4q59jl0sdqab-zstd/bin/zstd -d $dir/bin
+ 7za e "$self" nix/store/19p4fzsi2cfplknv2mpz4q59jl0sdqab-zstd/bin/zstd -o$dir/bin -y
chmod +wx $dir/bin/zstd;
- unzip -qqoj "$self" nix/store/qim5npfpw89nzzq1iwmr8zhbiilar2n7-proot/bin/proot -d $dir/bin
+ 7za e "$self" nix/store/qim5npfpw89nzzq1iwmr8zhbiilar2n7-proot/bin/proot -o$dir/bin -y
chmod +wx $dir/bin/proot;
- unzip -qqoj "$self" nix/store/c9ji7k8kmdpfj2mnh1rjpdg7wpbdxs2b-bwrap/bin/bwrap -d $dir/bin
+ 7za e "$self" nix/store/c9ji7k8kmdpfj2mnh1rjpdg7wpbdxs2b-bwrap/bin/bwrap -o$dir/bin -y
chmod +wx $dir/bin/bwrap;
- unzip -qqoj "$self" nix/store/shc7yym58533x9xl3d0ppci7nhzi9ri3-nix/bin/nix -d $dir/bin
+ 7za e "$self" nix/store/shc7yym58533x9xl3d0ppci7nhzi9ri3-nix/bin/nix -o$dir/bin -y
chmod +wx $dir/bin/nix;
# install ssl cert bundle
- unzip -poj "$self" nix/store/ydsac02yjmww0xgs3qdxislmky4q43l1-cacerts | $dir/bin/zstd -d > $dir/ca-bundle.crt
+ 7za e -so "$self" nix/store/ydsac02yjmww0xgs3qdxislmky4q43l1-cacerts | $dir/bin/zstd -d > $dir/ca-bundle.crt
recreate_nix_conf
fi
Line 28362:
-unzip -qqp "$self" nix/store/rfp19y4z6d3ahpg6kgygqq0z51l9zdyn-nix-portable-store-tarball/tar | $dir/bin/zstd -d | tar -x $missing --strip-components 2
+7za e -so "$self" nix/store/rfp19y4z6d3ahpg6kgygqq0z51l9zdyn-nix-portable-store-tarball/tar | $dir/bin/zstd -d | tar -x $missing --strip-components 2
The next error I got was for the find
command:
find: ‘/’: Permission denied
Find is trying to access root, but that's not something you can even look at on Android using Termux without root. This is where I really show that I have no idea what I'm doing. 😅 From what I understand there's certain system folders needed, like /dev/
that can't be linked fully on Android? This is something I'll look into in a bit.
Looking on my NixOS laptop the command that files delivers this list of files:
/root
/mnt
/run
/sys
/usr
/boot
/srv
/lib64
/bin
/etc
/var
/home
/proc
/tmp
/lost+found
/lib
So I set it to the root path of Termux: /data/data/com.termux.com/files
/data/data/com.termux/files/apps
/data/data/com.termux/files/home
/data/data/com.termux/files/rList
/data/data/com.termux/files/usr
/data/data/com.termux/files/system
/data/data/com.termux/files/vendor
/data/data/com.termux/files/data
/data/data/com.termux/files/apex
/data/data/com.termux/files/linkerconfig
/data/data/com.termux/files/storage
/data/data/com.termux/files/bin
/data/data/com.termux/files/etc
/data/data/com.termux/files/lib
/data/data/com.termux/files/share
/data/data/com.termux/files/tmp
/data/data/com.termux/files/var
/data/data/com.termux/files/proc
Line 28194:
- pathsTopLevel="$(find / -mindepth 1 -maxdepth 1 -not -name nix -not -name dev)"
+ pathsTopLevel="$(find /data/data/com.termux/files -mindepth 1 -maxdepth 1 -not -name nix -not -name dev)"
After all that, when run without an argument the script said:
Error: please specify the nix binary to execute
Alternatively symlink against ./nix-portable
Success? No. Attempting to actually run anything (like ./nix-portable nix run nixpkgs#htop
or even included packages like ./nix-portable pwd
) gives yet another error:
Fatal Error: nix is unable to build packages
After setting NP_DEBUG
to 1, the output after filtering out all the 7zip spam is:
installing files
figuring out ssl certs
SSL_CERT_FILE not defined. trying to find certs automatically
/etc/ssl/certs does not exist. Will use certs from nixpkgs.
figuring out which runtime to use
bwrap executable: /data/data/com.termux/files/home/.nix-portable/bin/bwrap
nix executable: /data/data/com.termux/files/home/.nix-portable/bin/nix
proot executable: /data/data/com.termux/files/usr/bin/proot
testing all available runtimes...
runtime selected via NP_RUNTIME: proot
NP_RUNTIME: proot
base command will be: /data/data/com.termux/files/usr/bin/proot -r /data/data/com.termux/files/home/.nix-portable/emptyroot -b /dev:/dev -b /data/data/com.termux/files/home/.nix-portable/nix:/nix -b /data/data/com.termux/files/apps:/data/data/com.termux/files/apps -b /data/data/com.termux/files/home:/data/data/com.termux/files/home -b /data/data/com.termux/files/rList:/data/data/com.termux/files/rList -b /data/data/com.termux/files/usr:/data/data/com.termux/files/usr -b /data/data/com.termux/files/system:/data/data/com.termux/files/system -b /data/data/com.termux/files/vendor:/data/data/com.termux/files/vendor -b /data/data/com.termux/files/data:/data/data/com.termux/files/data -b /data/data/com.termux/files/apex:/data/data/com.termux/files/apex -b /data/data/com.termux/files/linkerconfig:/data/data/com.termux/files/linkerconfig -b /data/data/com.termux/files/storage:/data/data/com.termux/files/storage -b /data/data/com.termux/files/bin:/data/data/com.termux/files/bin -b /data/data/com.termux/files/etc:/data/data/com.termux/files/etc -b /data/data/com.termux/files/lib:/data/data/com.termux/files/lib -b /data/data/com.termux/files/share:/data/data/com.termux/files/share -b /data/data/com.termux/files/tmp:/data/data/com.termux/files/tmp -b /data/data/com.termux/files/var:/data/data/com.termux/files/var -b /data/data/com.termux/files/proc:/data/data/com.termux/files/proc -b /system/etc/hosts:/system/etc/hosts -b /system/etc/passwd:/system/etc/passwd -b /system/etc/group:/system/etc/group -b /data/data/com.termux/files/home:/data/data/com.termux/files/home -b /data/data/com.termux/files/home/.nix-portable/ca-bundle.crt:/data/data/com.termux/files/home/.nix-portable/ca-bundle.crt
Testing if nix can build stuff without sandbox
Fatal error: nix is unable to build packages
/data/data/com.termux/files/home/.nix-portable/nix/store/1kykyij2ajl0yf5cjq764nzjpama17kj-nix-2.20.6/bin/nix: error while loading shared libraries: /nix/store/17f0lq1gmx0zmzqnhal6sj33zy0n1i21-glibc-2.37-45/lib/libc.so: invalid ELF header
./nix-portable: line 1: /tmp/np_env: No such file or directory
As far as I can tell the only important part is:
/nix/store/17f0lq1gmx0zmzqnhal6sj33zy0n1i21-glibc-2.37-45/lib/libc.so: invalid ELF header
And I have no idea how to fix that.
I assume this either has to do with the pathsTopLevel
variable and/or something necessary not being compiled for the bionic
c compiler Android uses. I'll keep trying to figure out what I need to do, but if anyone has any ideas or documentation I should be looking through, please let me know. 👍
I just downloaded the aarch64 version, chmod +x then run without parameters. I might hack around with this later.
It's a Redmi Note 5 Pro (whyred) running the latest stock that is based on Android 9.