-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nix package manager #59
Comments
Thanks for the suggestion @nico202! Will probably require PRoot, which is not available yet. Leaving this open as a reminder (will probably go through all issues that are package suggestions and collect them in a wiki soon)! |
Closing this now that https://github.com/termux/termux-packages/wiki/Package-suggestions contains package suggestions. |
Hi, I am reopening this issue. Package requests will now be labeled and tracked as an issue. |
Looks like proot exists now so might be able to make this work, even including caching. |
I'm not sure why proot would be necessary; AFAIK, nix just puts a bunch of stuff in /nix (or wherever you tell it to at build time) and does some symlink/path hackery to make the system look normal. In any case, I've been working for a few days on getting nix on termux (if it works as well as I hope, it'll be far more elegant than re-packaging the entire world in termux-land, IMO). I got it to build, though Perl caused a bunch of issues that seem broken to me, but I just followed the path of least resistance and fixed it in place. (That describes my general approach; I do post-configure patching of Makefile.config because it's easier than trying to find the right flags to pass to configure to do the right thing ;) ) I've added a new package in my tree below, which (if I haven't forgotten anything) should build a nice nix-env binary (along with the others). Unfortunately, running them (on a Nexus 5 or sdk emulator) fails with a mysterious I'd love a hand from more experienced C++ and/or android developers on how to troubleshoot this; none of the android glibc memory debugging seems to help, and staring at the code isn't getting me anywhere. If anyone wants to take a look: https://github.com/edanaher/termux-packages/tree/nix-wip |
Well, after building and installing valgrind (PR in #310), it clearly showed an attempt to free _ZNSs4_Rep20_S_empty_rep_storageE; Googling this turned up a similar issue in MySQL from a few years back; in short, it looks like stl uses a global empty string for all fresh allocations, and then the destructor makes sure not to free this when it goes out of scope. Unfortunately, despite the code in the android sdk appearing to do the right thing, this isn't working for nix binaries. AFAICT, the MySQL issue was due to it creating a second copy of this magic empty string, so one of them didn't pass the check to avoid being freed. Time to keep digging... |
Finally! As is so often the case, a tangentially related stackoverflow post had the key:
That fits in nicely with the duplicated symbol in MySQL. (And I'll probably add a note in the "Common porting problems" on this, to help future packagers.) With this, nix builds, but for some reason not all the Perl modules are being installed, so it's not there yet. But this looks back to more straightforward "find the issue and fix it", rather than digging around deep in C++/linker land. |
... and things now come close to working. With lots more hacking (including building Perl modules on the device... ew...), things are now failing because the script for unpacking channels (which appears to come from the channel itself) has a bunch of hardcoded /bin and /usr/bin paths for bash, tar, etc. I think I need to take a break from this, but if anyone wants to pick it up, my work is at https://github.com/edanaher/termux-packages/tree/nix-wip . (with the additional bit that to get the Perl modules to build,
|
Has anyone managed to make more progress on this? Would love to be able to share nix configuration files between my laptop and phone. |
I haven't, though I've been thinking about making another go at it in the near future; your comment might push me to do it. |
I'd donate 5€ to get it in the near future if this can help XD |
This would turn toys into semi-computers. Should just entirely replace apt with nix. |
@edanaher Still interested in it? |
I did take another swing, but unfortunately had issues with changes to the system in the past year, and ended up spending the time (mostly successfully) trying to get termux to build via nix, rather than building nix via termux ;) I'm still interested; it's just fairly low priority and other things keep coming up. Maybe these comments will help motivate me. (And while I'm not going to take the donation if I do end up doing it, the fact that someone is willing to pay is actually surprisingly meaningful to me.) |
Alright; some free time tonight got me to realize that my build issues were due to my "cleanups" of the year-old termux build system interacting poorly with the newer (and rather nice) build. I got roughly back to where I was before, but with non-trivial issues due to changes in libcurl breaking WWW::Curl. AFAICT, there's a patch for the issue, but I don't see how to apply it as part of the build, because cpan is black magic to me. I re-examined another path from a while back; ignoring termux and just using Nix to cross-compile itself for ARM, and then dumping the closure for nix-env into termux. (This should work without any of the android hackery termux uses, since it's self-contained, with it's own glibc and everything.) I got bash to cross-compile beautifully, running on my phone (Pixel) with minimal work (and termux-chroot to put the store in /nix), but sadly, cross-compiling nix itself was failing due to, shockingly enough, issues with the perl modules. However, it turns out that Nix no longer depends on Perl: NixOS/nix@915f62f! It just requires using a prerelease Nix 1.12, which I'm currently building as a cross-compile, though I would expect it to also be plausible to build it via termux as well. So with the long-awaited rewrite of the Perl code into C++, I suspect Nix-on-termux is imminent. |
Thanks @edanaher, I got Nix 1.12 building in Termux: https://github.com/puffnfresh/termux-packages/tree/package/nix/packages/nix There were a few workarounds needed because of the NDK. Of course, running Nix isn't working for me because my root is read-only and so it can't create /nix - running it in proot gets me a bit further. I'll see if I can build a simple derivation. |
@puffnfresh - Awesome! I wasn't looking forward to plowing through the various android ndk shortcomings (to be fixed in "the next version" every version since r9...), but looks like you got it done. I've been testing by simply using "termux-chroot", which nicely wraps proot to do what you want. Sadly, on my (aarch64) Pixel, I'm getting nasty errors even before it gets to looking for /nix; even just --help fails:
On the segfaults, I've gotten two different stack traces:
Maybe one time in twenty I'll get an error that there's no man page for it, suggesting that it worked. So there's something nasty and nondeterministic going on. |
@edanaher urgh, I don't have that problem. I think we'll have to use gdb on that 😿 Using termux-chroot I have a working /nix, but I can't realise "nix-channels" because the builder is /bin/bash, which needs LD_LIBRARY_PATH to be set so it can find libandroid-support.so - of course Nix doesn't want to run a builder with that in the environment. I tried to use patchelf to set the rpath but that doesn't seem to have done anything. |
Judging from #498 (comment), it looks like the Android linker doesn't use rpath. I might have to write a dodgy wrapper around /bin/bash |
An update, I had to do some massive hacks but I am able to get Nix to give me binaries. For example, nix-repl: And Emacs: There's a few problems:
I'll try to package my dodgy scripts and put them in a fork. |
Terrific news! Thank you for the update and for your hard work! |
I have something for you to try out over here: |
I've successfully installed nix under proot |
I've successfully compiled nix 2.0.2 in termux with just configure, make and a couple of minor changes in config.h and source code, but it is failing at the linking phase because libboost_context is missing in termux boost package. |
after fixing libboost_context missing asm functions #2384 I have completed the linking phase and have the Nix executables installed in a local prefix. Here's my current configure
Problem. Each execution complains about missing
I've also tried installing it with Any idea? |
By fixing manually
|
I've managed how to initiate nix bootstrap, but it is failing in glob expansion. More details here |
Hi everyone, I have new updates. Here is what I have done so far:
So far the script
here the error message
Using the nix-provided Any idea on how to trobleshoot the error? |
@ineff Verify that file /etc/resolv.conf has nameserver entries. |
@xeffyr there is no /etc/resolv.conf in termux, what is more is that standard commands as curl and wget work fine. |
I think I figured it out. https://github.com/t184256/nix-in-termux Quickstart:
Reddit post: https://www.reddit.com/r/NixOS/comments/avv87s/i_succeeded_in_running_nix_on_android_for_now/ |
How about adding https://github.com/nix-community/nix-user-chroot as a package? |
So readme of https://github.com/nix-community/nix-user-chroot says:
Android kernels don't support user namespaces at all. So nix-user-chroot will not be added. |
Is this true for Chromium OS as well? It looks like the kernel may have it enabled, but I don't know if the feature is usable in the Android runtime: https://chromium.googlesource.com/chromium/src/+/lkgr/docs/linux_sandboxing.md#user-namespaces-sandbox |
Kernel may have it enabled. But are they allowed for unprivileged users ? Answer to questions you can find with simple command (package unshare --user --pid echo "userns allowed" If they allowed, you will see
If not:
If they are not supported:
|
Aha, thank you. Just checked on a Samus (pixel 2015) running ChromeOS 72.0.3626.122: $ uname -a
Linux localhost 3.14.0 #1 SMP PREEMPT Sun Mar 3 23:00:05 PST 2019 i686 Android
$ unshare --user --pid echo "userns allowed"
unshare: unshare failed: Operation not permitted (the It may be worth having someone check this on a more recent chromebook that has Crostini support, because they have a bunch of new kernel features not enabled in the chromium 3.14 kernel. But then again, on a chromebook that can run crostini containers/VMs, users are less likely to need termux in the first place. |
Could somebody explaint what's the problem with that? I can use Nix just fine if I disable sandboxing. Do you value that feature so much that it's a showstopper for you? In addition to the script I've posted above, I have also packaged Nix as a separate app. You can try it for yourself by installing https://transfer.sh/46PBk/nix-on-droid.apk or looking how I made it work at https://github.com/t184256/nix-on-droid-app and https://github.com/t184256/nix-on-droid-bootstrap. If there's a particular use case that neither of my creations can cover, I'm all ears. I really want to bring Nix to Android, what can I do for you? |
I'm currently trying to package the nix package manager again, just hit a bug and waiting for my issue to be fixed or I need to come up with a patch for now. |
The reason of closing this is the same as a reason for closing guix-related issue #3240. Building package-manager does not let us bring it's packages. Porting package should be done individually, we already do this for other packages. |
From @nico202 on November 19, 2015 15:58
Hi, has someone tried getting nix to work inside termux? This would mean to have lot of packages available.
Here's a guide to get it on various distro.
Thanks, Nicolò
Copied from original issue: termux/termux-app#18
The text was updated successfully, but these errors were encountered: