Git Product home page Git Product logo

nix-on-droid's Introduction

Nix-on-Droid

Get it on F-Droid

Nix package manager on Android, in a single-click installable package. This is not full NixOS running inside Android, but you get easy access to nixpkgs' vast collection of (precompiled!) software and the best package manager under the sun. It's prototype-grade quality as of now, but hey, it works!

It does not require root, user namespaces support or disabling SELinux, but it relies on proot and other hacks instead. It uses a fork of Termux-the-terminal-emulator app, but has no relation to Termux-the-distro. Please do not pester Termux folks about Nix-on-Droid.

This repository contains:

  1. Nix expressions that generate a bootstrap zipball, which is then used to install Nix package manager on Android along with the nix-on-droid executable.
  2. A module system for configuring the local Nix-on-Droid installation directly on the device.

It is only tested with aarch64 (64-bit ARM devices). It also used to compile for i686 devices, but the developers don't own any and nobody has reported whether it actually worked or not, so it's no longer built unless a user shows up. Sorry, it would not work on 32-bit ARM devices and it's not an easy feat to pull off.

Try it out

Install it from F-Droid, launch the app, press OK, expect many hundreds megabytes of downloads to happen.

Nix-on-Droid and the module system

Config file

The Nix-on-Droid system can be managed through a custom config file in ~/.config/nixpkgs/nix-on-droid.nix as generated on first build, for example:

{ pkgs, ... }:

{
  environment.packages = [ pkgs.vim ];
  system.stateVersion = "23.11";
}

An alternative location is ~/.config/nixpkgs/config.nix with the key nix-on-droid, for example:

{
  nix-on-droid =
    { pkgs, ... }:

    {
      environment.packages = [ pkgs.vim ];
      system.stateVersion = "23.11";
    };
}

See https://nix-community.github.io/nix-on-droid/ for list of all available options.

home-manager integration

To enable home-manager you simply need to follow the instructions already provided in the example nix-on-droid.nix:

  1. Add home-manager channel:
    nix-channel --add https://github.com/nix-community/home-manager/archive/release-23.11.tar.gz home-manager
    nix-channel --update
  2. Configure home-manager:
    { pkgs, ... }:
    
    {
      # Read Nix-on-Droid changelog before changing this value
      system.stateVersion = "23.11";
    
      # insert Nix-on-Droid config
    
      home-manager.config =
        { pkgs, ... }:
        {
          # Read home-manager changelog before changing this value
          home.stateVersion = "23.11";
    
          # insert home-manager config
        };
    
      # or if you have a separate home.nix already present:
      home-manager.config = ./home.nix;
    }

nix-on-droid executable

This executable is responsible for activating new configurations: Use nix-on-droid switch to activate the current configuration and nix-on-droid rollback to rollback to the latest build.

For more information, please run nix-on-droid help.

Build Nix-on-Droid on your own

The terminal emulator part is probably not interesting for you, just download and use a prebuilt one. If you really want to rebuild it, you can just use Android Studio for that.

The zipball generation is probably what you are after. Get an x86_64 computer with flake-enabled Nix.

tl;dr: Use the deploy app like the following which executes all steps mentioned below:

nix run ".#deploy" -- <public_url> <rsync_target>
# or run the following for explanation of this script
nix run ".#deploy"

Run

nix build ".#bootstrapZip" --impure

Put the zip file from result on some HTTP server and specify the parent directory URL during the installation. To re-trigger the installation, you can use 'clear data' on the Android app (after backing stuff up, obviously).

If you want to change the Nix-on-Droid channel to your custom one, you can do that either with nix-channel after the installation, or by setting the environment variable NIX_ON_DROID_CHANNEL_URL. Other environment variables are NIXPKGS_CHANNEL_URL an NIX_ON_DROID_FLAKE_URL.

Note: The proot binary is not built on the android device (NDK is required for building it, and it's not available on mobile platforms). The way we work around it is to push proot derivation to cachix. The current workaround is to hardcode the path to the wanted proot nix store path in modules/environment/login/default.nix. During evaluation time on the android device this store path will be downloaded from the binary cache (https://nix-on-droid.cachix.org/). This in return means the proot derivation has to be present there or in any other binary cache configured in the nix.conf on the device.

Obviously it's an annoyance if one wants to fork this repo and test something. To minimize the hassle with this scenario, proot derivation is also bundled with the bootstrap zipball. This way you only need your own binary cache if you are planning to maintain a long-term fork that users can update from. In case you only care about updates through wiping the data, or are forking to submit a one-off pull request, you shouldn't need a binary cache for that.

Nix flakes

Note: Nix flake support is still experimental at the moment and subject to change.

Examples / templates

A minimal example could look like the following:

{
  description = "Minimal example of Nix-on-Droid system config.";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";

    nix-on-droid = {
      url = "github:nix-community/nix-on-droid/release-23.11";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, nixpkgs, nix-on-droid }: {

    nixOnDroidConfigurations.default = nix-on-droid.lib.nixOnDroidConfiguration {
      modules = [ ./nix-on-droid.nix ];
    };

  };
}

For more examples and nix flake templates, see templates directory or explore with:

nix flake init --template github:nix-community/nix-on-droid#advanced

Usage with nix-on-droid

Use nix-on-droid switch --flake path/to/flake#device to build and activate your configuration (path/to/flake#device will expand to .#nixOnDroidConfigurations.device). If you run nix-on-droid switch --flake path/to/flake, the default configuration will be used.

Note: Currently, Nix-on-Droid can not be built with an pure flake build because of hardcoded store paths for proot. Therefore, every evaluation of a flake configuration will be executed with --impure flag. (This behaviour will be dropped as soon as the default setup does not require it anymore.)

Emulate Nix-on-Droid-like environment with fakedroid

For easier debugging and testing, there is a so-called fakedroid environment which emulates the on-device environment including proot as good as possible.

You can enter this emulated environment with

nix run --impure ".#fakedroid"

This will install Nix-on-Droid with initial channel setup and save the state of this session in the .fakedroid directory in the project directory. To enter this environment with initial flake setup, set USE_FLAKE=1 as environment variable. Channel and flake setups can co-exist in the .fakedroid state directory. To rebuild/re-test the bootstrap process, remove the .fakedroid directory.

To only run a command in fakedroid and not enter an interactive shell, just call it with the command as arguments:

nix run --impure ".#fakedroid" -- ls -l

Testing

In the ./tests/on-device directory, there is small set of bats tests that can be executed on the android device or run in the fakedroid environment.

To run the tests (on device or in fakedroid), run

nix-on-droid on-device-test

Note: This currently requires a channel setup and should only be executed on clean installations.

Tips

  • To grant the app access to the storage, use the toggle in the app settings (reachable from Android settings).
  • If the terminal freezes, use 'Acquire wakelock' button in the notification and/or tone down your device's aggressive power saving measures.
  • We have a wiki with tips and success stories, you're encouraged to add yours as well.

Technical overview

OK, real brief.

Developer's device:

  1. proot for the target platform is cross-compiled against bionic, (to fake file paths like /nix/store; think 'userspace chroot')
  2. Target nix is taken from the original release tarball
  3. Target nix database is initialized
  4. Support scripts and config files are built with nix and the Nix-on-Droid module system
  5. From these, a bootstrap zipball is built and published on an HTTP server

User's device:

  1. Android app is installed and launched, bootstrap URL is entered
  2. Bootstrap zipball gets downloaded and unpacked
  3. 'First boot' begins, Nix builds the environment (or, possibly, pulls it from Cachix)
  4. Nix installs the environment (login scripts, config files, etc.)

You can refer to a NixCon 2019 presentation talk for a more extensive overview of the subject.

Licensing and credits

Licensed under MIT License, see LICENSE. Copyright (c) 2019-2021 Alexander Sosedkin and other contributors, see AUTHORS.

Two rewrites ago it was based off the official Nix install script (https://nixos.org/nix/install), presumably written by Eelco Dolstra.

Is deployed and used with a fork of Termux-the-terminal-emulator app, but has no relation to Termux-the-distro.

Previous project that did use Termux-the-distro: https://github.com/t184256/nix-in-termux

nix-on-droid's People

Contributors

573 avatar azuwis avatar bbigras avatar gerschtli avatar jrobsonchase avatar kurnevsky avatar lucasew avatar mtoohey31 avatar phanirithvij avatar reo101 avatar shamrocklee avatar socksthefennec avatar t184256 avatar zhaofengli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nix-on-droid's Issues

Support aarch64 devices with 32-bit Android

Samsung ARM64 devices with 2GB of RAM and lower run using a 32-bit Android userspace but an AArch64 kernel.

That includes the Galaxy A10, released in 2019 on Android 9, despite using a Cortex-A73.

Screenshot_20191213-192840_Termux

In that case, statically linked binaries work just fine, so proot would have to be statically linked for aarch64 and the package to be marked as armv7 compatible...

X11 with VNC, Fatal server error: (EE) Failed to activate virtual core keyboard: 2(EE) , termux workaround

Update: termux not needed with #75 (comment)

I've been fiddling with #34 , and made something akin to progress, but there are some issues;

  • strace doesnt work, so I'm not sure how to figure out why Xvfb isn't working. GDB works but I don't know how to deal with multithreaded-processed things with it. #76
  • the hybridization approach seems to leave everything visible in VNC hanged, whatever that means.*

cc @ShamrockLee

As a temporary workaround for #34, I tried installed and running X11 in termux.
I successfully installed and ran Xvfb, and connected nix-built applications to the remote display via the $DISPLAY variable over the loopback device. So a hybrid termux/nix-on-droid approach seems to work*.

A thrown together tutorial (no authentication, etc, the point was just to see if I can even get this to work):

  • Install termux and nix-on-droid from F-Droid
  • install a VNC app like VNC Viewer (by RealVNC) from the play store, or MultiVNC from F-Droid. Sadly the UI design of the former seems to work somewhat better. For example: the MultiVNC keyboard overlaps with the screen area for me, which is irritating bk138/multivnc#76 (comment)
  • keep installing stuff until termux is happy; the main things needed are tigervnc, providing the vncserver and x0vncserver commands, which spawn an Xvnc process, and the X11 stuff which provides Xvnc, Xvfb, etc.
  • in nix, load a shell with something like awesomewm and xclock for testing
  • TERMUX: run Xvfb to start an X server. It seems not to expose a network port by default so we make it listen on a port, and we disable host based authentication (TODO: check the auth disabling is needed): Xvfb -listen tcp -ac &
  • TERMUX: run x0vncserver to attach a vnc server to an existing display (TODO: check how to do it without password) (TODO: check if setting env var is needed) (TODO: the passwd file is created by running vncserver probably?): DISPLAY=:0 x0vncserver -rfbauth /data/data/com.termux/files/home/.vnc/passwd
    Edit: NIX: start a nix-shell with x11vnc and run DISPLAY=127.0.0.1:0 x11vnc -passwd whatever -rfbport 5901 -noshm -forever see #75 (comment)
  • NIX: export DISPLAY=127.0.0.1:0 && awesome & xclock &
  • VNC CLIENT: connect to 127.0.0.1:5900 with the set password (or whatever port, check with netstat) and enjoy your frozen windows

TODO: script that sshes to the termux and handles everythig in one place

TODO: build proot on-device

For full management of the system and smooth upgrade path that was laid out in #18 we should also manage proot with nix and make it buildable on-device (and cache the result so that the users won't actually have to do that). Ironically, now it's easier to cross-compile that to native-compile it, as it has to be linked with bionic.

Maybe it'd be acceptable to just ape the build environment from termux and use LLVM. Maybe not.

home-manager: no .bashrc

I installed home-manager and I set programs.starship.enable = true; which should add stuff to .bashrc but I don't seem to have one.

Unable to upgrade nix-channels

Hello, I'm trying to run nix on my Android 6 machine. Bootstrap downloaded succesfully. But I'm stuck on first update of the nix-channels. Read somewhere it probably has something to do with https, so I edited the .nix-channels from failsafe. But apparently after I closed the failsafe the content of .nix-channels is reverted back to before I edited it.

I'm new with nix so I kinda clueless. What can I do to fix this?

Thank you.

Has nix-on-droid user a password ?

I am trying to follow https://github.com/t184256/nix-on-droid/wiki/SSH-access

When I do ssh-copy-id

nix run nixpkgs.openssh -c ssh-copy-id -p 8022 -i ~/.ssh/phone nix-on-droid@<ip>

from my remote machine while running

nix run nixpkgs.openssh -c /nix/store/(...)/bin/sshd -f sshd_config_local -ddd

on the phone (nix-on-droid) I am getting

/nix/store/wdbg7kyylmvg48w0wklrjdhvgya4lcgi-openssh-8.2p1/bin/ssh-copy-id: ERROR: ssh: connect to host port 8022: Connection refused

I had to run the following in order to run the previous command

touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

When I'm trying

nix run nixpkgs.openssh -c ssh -p 8022 -i ~/.ssh/phone -l nix-on-droid <ip>

I am getting

nix-on-droid@'s password:

My question would be is there a password for nix-on-droid user ?

Building proot is not automated

Unfortunately my attempts for naively cross-compiling static-linked proot as pkgsCross.armv7a-android-prebuilt.pkgsStatic.proot or pkgsCross.aarch64-multiplatform.pkgsStatic.proot failed: the produced binaries crashed with the dreaded bus error that I don't know how to debug, so I resorted to building proot manually for now.

This may be a desperate shot in the dark, but when I type 'cross-compiling static-linked... with nix`, there's a name that rings inside my head and this name is @matthewbauer. Matthew, if you have a minute, do you have any insights on why could that produce a binary that crashes with 'Bus error'? Have you tried combining crossSystem and pkgsStatic?

Visualisation of available options

I would like to have a auto-generated list of all available options, similar to home-manager's html page or as output of man nix-on-droid.

I'm open for ideas where and how to implement this.

home manager wont install on any device

i can't get home manager to install on any devices, i have tried it on 6 devices so far

hauwei mate SE
google pixel
samsung tab S
samsung s6, s7
hauwei media pad
samsung note 4

its all the same error, i will attach an image because select all doesn't work on this lovely little app and it files i write in nix-on-droid are for some reason impossible to find on android (thanks for that)

I've attached images of it

Screenshot_20200101-213604_Nix (1)
Screenshot_20200101-211922

There will be no further complaints from me here, this is broken garbage and i wish you the best of luck fixing it

uninstalled thanks

emacs error 'User xxxx has no home directory'

bash-4.4$
bash-4.4$ ls .em*
ls: cannot access '.em*': No such file or directory
bash-4.4$ emacs

Results in:

Error (initialization): User u0_a211 has no home directory

You can get past it with:

emacs --load emacs-config/init.el --user ''

Maybe there is a better solution?

can't build exa

not sure if related to #8

I tried to install 'exa' with home-manager. I get those error.

The weird thing is that if I run home-manager switch again I don't have any errors but I can't run the exa command. I get command not found.

Do I need the storage permission for this or is the permission only so I can access my phone's file from Nix?

first home-manager run:

GC Warning: Couldn't read /proc/stat
GC Warning: Couldn't read /proc/stat
these derivations will be built:
  /nix/store/06fi3aigs1wlbbbd3b4q6hfg7nly33ka-exa-0.8.0.drv
  /nix/store/pqchpgln0fakk3qpqavim71la1617qzc-home-manager-path.drv
  /nix/store/hz5c6218yf1k6px4zb3xa6g02j10gd4m-activation-script.drv
  /nix/store/2175bk5bi1bv4lpldc4h9d5a2bkny7sy-home-manager-generation.drv
these paths will be fetched (152.90 MiB download, 601.26 MiB unpacked):
  /nix/store/088br4d3rk7lhpxnpfrifkhsk1f1ahbn-pkg-config-0.29.2
  /nix/store/0amchd0rpnarzvgrcarpxad8kly85ic5-perl5.28.1-HTTP-Date-6.02
  /nix/store/0dyywz80hkkndj6bighqq392ppszy7sf-perl5.28.1-Encode-Locale-1.05
  /nix/store/133di3cs8b8gbcg1850rdiffafwjr3lx-python-2.7.16
  /nix/store/2gvf6yxkzkd0mi0yss69dl56vhawv9lh-llvm-7.0.1-lib
  /nix/store/2v9zmq2nqygqk1sh0a29420na6ws55qs-gdbm-1.18.1
  /nix/store/380glr4r5jyhb6pk6kmdvivpnrpx37yi-openssh-7.9p1
  /nix/store/3wrcg1zy6k70pvf4dma3xv5h1kgqjxb1-gcc-wrapper-7.4.0
  /nix/store/4gr9c2161slg0x5r3lwqmkajb2da25rb-expat-2.2.6
  /nix/store/50792v9mrzxja3cc4s3i7h2bcd0brb7z-perl5.28.1-Test-RequiresInternet-0.05
  /nix/store/53cms7ayg0hdm46g9g89dc5xzavvb8c6-git-2.19.2
  /nix/store/5d2pwfgk42p3knphm7rmcmqi79iazfyq-perl5.28.1-HTTP-Daemon-6.01
  /nix/store/5qj51mzplnxdfra88fxj7q0k5ki4r68a-binutils-2.31.1
  /nix/store/6dc1i53b00gqdp6mvav4f574admb38fl-linux-headers-4.19.16
  /nix/store/6l7v4g34mx6ycp1r3n46cgbimxf3m259-perl5.28.1-URI-1.74
  /nix/store/7a21rfc96j21bwnlfkjsz5zd8nc2xw9j-exa-0.8.0-vendor
  /nix/store/84q5kyffv30hbw80ywh05m4b18s0vhza-zlib-1.2.11-dev
  /nix/store/8ad1hjyd8464l74q2qn64sh6dzlzgkdq-rhash-1.3.8
  /nix/store/8k2szzqh9na9w64akfbyhxhw0nr4nw2z-perl5.28.1-libwww-perl-6.36
  /nix/store/8mkrm2kxv7zz02zza3xd33ldm6b0wiy7-perl5.28.1-HTML-Parser-3.72
  /nix/store/93c3l5pdxnmnrq8ryh0jaln7npp343ip-gcc-7.4.0
  /nix/store/9lqrs6ii8nzq58j62slwgmp6mmg9kyff-glibc-2.27-dev
  /nix/store/ab4nnspb6f8imn7wyxgrc3gy0i1cmdpc-expand-response-params
  /nix/store/b5j3wy8j2hvlhkh7zyy0fcxha9m5xkaq-stdenv-linux
  /nix/store/bqlj9j4pg202nafdjdy7chyrwf18myhr-libedit-20180525-3.1
  /nix/store/cy9k6b706yixdg6jwh4az9wr846dqnjk-perl5.28.1-Test-Needs-0.002005
  /nix/store/f8al0sbbbscxvq5xm6vqi2i086msbp4q-perl5.28.1-File-Listing-6.04
  /nix/store/fqwsi5mhrl6568c1rfx1jl8vxnvbvnvz-source
  /nix/store/fz4iksqmxv9dz096b7gbsbzw4sb47rf3-libgit2-0.26.6
  /nix/store/hyi769dbhf8p8sx70gnrpsamil6pb0qx-cmake-3.13.4
  /nix/store/iki0dvhrw9nvj1pmka9z0z4332r76ya4-readline-6.3p08
  /nix/store/jpajm1g87vmdbcslwf3n82phcq7xdhdq-gettext-0.19.8.1
  /nix/store/kfqsff3308ra0dbh3aig9xg9gv182spw-perl5.28.1-HTTP-Cookies-6.04
  /nix/store/kwgwvh7gr1xv56nfkjd3mpwcrx1vddky-libarchive-3.3.3-lib
  /nix/store/q9bm3i7zlxjmdv469spb6cma5cfih0ls-perl5.28.1-Test-Fatal-0.014
  /nix/store/qlgnvv94qba9c7zi3bif04z730k5pwgs-perl5.28.1-IO-HTML-1.001
  /nix/store/r047a4brgc5yh9wdh63kxp0hhsx1y5xl-http-parser-2.9.0
  /nix/store/r1f6kq7pj7qgi6hs7jqzdi784r0qjlz5-binutils-wrapper-2.31.1
  /nix/store/ryq0pzfqdpjbzx9vxqyavw76zssrac7i-rustc-1.32.0
  /nix/store/sfmn4jykwrf9fgsahrmy28ww0hgd3lv2-perl5.28.1-TermReadKey-2.37
  /nix/store/sl99nsf27mgfmigcnbh1nxkyvzjvmvg1-perl5.28.1-HTML-Tagset-3.20
  /nix/store/vj0mnryjvfcv8302wrdrxmda8da9kc46-libuv-1.26.0
  /nix/store/vyx4da3sk0jnybbks1717rklvv0zd659-perl5.28.1-Try-Tiny-0.30
  /nix/store/w56xmk58q44czl33jn9gl5f310ff1akc-perl5.28.1-WWW-RobotRules-6.02
  /nix/store/x90hsr3ww113rz0658w6ay3rvlgmp5y3-perl5.28.1-Net-HTTP-6.18
  /nix/store/xk02njxh2v1hvqpvwp3i91yrk5q06wfw-perl5.28.1-HTTP-Message-6.18
  /nix/store/ynxlmwlhczm5y4i2qwxjj3xw00nfxdiy-perl5.28.1-HTTP-Negotiate-6.01
  /nix/store/zc9zvgjig6mnccwbavx8kyrb5yzg7ns3-cargo-1.32.0
  /nix/store/zg2w3viqsc8cxpfwjaqif8jqfn6gcjn3-perl5.28.1-LWP-MediaTypes-6.02
copying path '/nix/store/7a21rfc96j21bwnlfkjsz5zd8nc2xw9j-exa-0.8.0-vendor' from 'https://cache.nixos.org'...
copying path '/nix/store/5qj51mzplnxdfra88fxj7q0k5ki4r68a-binutils-2.31.1' from 'https://cache.nixos.org'...
copying path '/nix/store/ab4nnspb6f8imn7wyxgrc3gy0i1cmdpc-expand-response-params' from 'https://cache.nixos.org'...
copying path '/nix/store/4gr9c2161slg0x5r3lwqmkajb2da25rb-expat-2.2.6' from 'https://cache.nixos.org'...
copying path '/nix/store/2v9zmq2nqygqk1sh0a29420na6ws55qs-gdbm-1.18.1' from 'https://cache.nixos.org'...
copying path '/nix/store/jpajm1g87vmdbcslwf3n82phcq7xdhdq-gettext-0.19.8.1' from 'https://cache.nixos.org'...
copying path '/nix/store/r047a4brgc5yh9wdh63kxp0hhsx1y5xl-http-parser-2.9.0' from 'https://cache.nixos.org'...
copying path '/nix/store/kwgwvh7gr1xv56nfkjd3mpwcrx1vddky-libarchive-3.3.3-lib' from 'https://cache.nixos.org'...
copying path '/nix/store/bqlj9j4pg202nafdjdy7chyrwf18myhr-libedit-20180525-3.1' from 'https://cache.nixos.org'...
copying path '/nix/store/fz4iksqmxv9dz096b7gbsbzw4sb47rf3-libgit2-0.26.6' from 'https://cache.nixos.org'...
copying path '/nix/store/vj0mnryjvfcv8302wrdrxmda8da9kc46-libuv-1.26.0' from 'https://cache.nixos.org'...
copying path '/nix/store/6dc1i53b00gqdp6mvav4f574admb38fl-linux-headers-4.19.16' from 'https://cache.nixos.org'...
copying path '/nix/store/2gvf6yxkzkd0mi0yss69dl56vhawv9lh-llvm-7.0.1-lib' from 'https://cache.nixos.org'...
copying path '/nix/store/9lqrs6ii8nzq58j62slwgmp6mmg9kyff-glibc-2.27-dev' from 'https://cache.nixos.org'...
copying path '/nix/store/380glr4r5jyhb6pk6kmdvivpnrpx37yi-openssh-7.9p1' from 'https://cache.nixos.org'...
copying path '/nix/store/r1f6kq7pj7qgi6hs7jqzdi784r0qjlz5-binutils-wrapper-2.31.1' from 'https://cache.nixos.org'...
copying path '/nix/store/93c3l5pdxnmnrq8ryh0jaln7npp343ip-gcc-7.4.0' from 'https://cache.nixos.org'...
copying path '/nix/store/0dyywz80hkkndj6bighqq392ppszy7sf-perl5.28.1-Encode-Locale-1.05' from 'https://cache.nixos.org'...
copying path '/nix/store/3wrcg1zy6k70pvf4dma3xv5h1kgqjxb1-gcc-wrapper-7.4.0' from 'https://cache.nixos.org'...
copying path '/nix/store/sl99nsf27mgfmigcnbh1nxkyvzjvmvg1-perl5.28.1-HTML-Tagset-3.20' from 'https://cache.nixos.org'...
copying path '/nix/store/0amchd0rpnarzvgrcarpxad8kly85ic5-perl5.28.1-HTTP-Date-6.02' from 'https://cache.nixos.org'...
copying path '/nix/store/8mkrm2kxv7zz02zza3xd33ldm6b0wiy7-perl5.28.1-HTML-Parser-3.72' from 'https://cache.nixos.org'...
copying path '/nix/store/f8al0sbbbscxvq5xm6vqi2i086msbp4q-perl5.28.1-File-Listing-6.04' from 'https://cache.nixos.org'...
copying path '/nix/store/qlgnvv94qba9c7zi3bif04z730k5pwgs-perl5.28.1-IO-HTML-1.001' from 'https://cache.nixos.org'...
copying path '/nix/store/zg2w3viqsc8cxpfwjaqif8jqfn6gcjn3-perl5.28.1-LWP-MediaTypes-6.02' from 'https://cache.nixos.org'...
copying path '/nix/store/sfmn4jykwrf9fgsahrmy28ww0hgd3lv2-perl5.28.1-TermReadKey-2.37' from 'https://cache.nixos.org'...
copying path '/nix/store/cy9k6b706yixdg6jwh4az9wr846dqnjk-perl5.28.1-Test-Needs-0.002005' from 'https://cache.nixos.org'...
copying path '/nix/store/50792v9mrzxja3cc4s3i7h2bcd0brb7z-perl5.28.1-Test-RequiresInternet-0.05' from 'https://cache.nixos.org'...
copying path '/nix/store/vyx4da3sk0jnybbks1717rklvv0zd659-perl5.28.1-Try-Tiny-0.30' from 'https://cache.nixos.org'...
copying path '/nix/store/6l7v4g34mx6ycp1r3n46cgbimxf3m259-perl5.28.1-URI-1.74' from 'https://cache.nixos.org'...
copying path '/nix/store/q9bm3i7zlxjmdv469spb6cma5cfih0ls-perl5.28.1-Test-Fatal-0.014' from 'https://cache.nixos.org'...
copying path '/nix/store/xk02njxh2v1hvqpvwp3i91yrk5q06wfw-perl5.28.1-HTTP-Message-6.18' from 'https://cache.nixos.org'...
copying path '/nix/store/x90hsr3ww113rz0658w6ay3rvlgmp5y3-perl5.28.1-Net-HTTP-6.18' from 'https://cache.nixos.org'...
copying path '/nix/store/kfqsff3308ra0dbh3aig9xg9gv182spw-perl5.28.1-HTTP-Cookies-6.04' from 'https://cache.nixos.org'...
copying path '/nix/store/5d2pwfgk42p3knphm7rmcmqi79iazfyq-perl5.28.1-HTTP-Daemon-6.01' from 'https://cache.nixos.org'...
copying path '/nix/store/ynxlmwlhczm5y4i2qwxjj3xw00nfxdiy-perl5.28.1-HTTP-Negotiate-6.01' from 'https://cache.nixos.org'...
copying path '/nix/store/w56xmk58q44czl33jn9gl5f310ff1akc-perl5.28.1-WWW-RobotRules-6.02' from 'https://cache.nixos.org'...
copying path '/nix/store/088br4d3rk7lhpxnpfrifkhsk1f1ahbn-pkg-config-0.29.2' from 'https://cache.nixos.org'...
copying path '/nix/store/8k2szzqh9na9w64akfbyhxhw0nr4nw2z-perl5.28.1-libwww-perl-6.36' from 'https://cache.nixos.org'...
copying path '/nix/store/iki0dvhrw9nvj1pmka9z0z4332r76ya4-readline-6.3p08' from 'https://cache.nixos.org'...
copying path '/nix/store/8ad1hjyd8464l74q2qn64sh6dzlzgkdq-rhash-1.3.8' from 'https://cache.nixos.org'...
copying path '/nix/store/133di3cs8b8gbcg1850rdiffafwjr3lx-python-2.7.16' from 'https://cache.nixos.org'...
copying path '/nix/store/hyi769dbhf8p8sx70gnrpsamil6pb0qx-cmake-3.13.4' from 'https://cache.nixos.org'...
copying path '/nix/store/53cms7ayg0hdm46g9g89dc5xzavvb8c6-git-2.19.2' from 'https://cache.nixos.org'...
copying path '/nix/store/ryq0pzfqdpjbzx9vxqyavw76zssrac7i-rustc-1.32.0' from 'https://cache.nixos.org'...
copying path '/nix/store/fqwsi5mhrl6568c1rfx1jl8vxnvbvnvz-source' from 'https://cache.nixos.org'...
copying path '/nix/store/zc9zvgjig6mnccwbavx8kyrb5yzg7ns3-cargo-1.32.0' from 'https://cache.nixos.org'...
copying path '/nix/store/b5j3wy8j2hvlhkh7zyy0fcxha9m5xkaq-stdenv-linux' from 'https://cache.nixos.org'...
copying path '/nix/store/84q5kyffv30hbw80ywh05m4b18s0vhza-zlib-1.2.11-dev' from 'https://cache.nixos.org'...
GC Warning: Couldn't read /proc/stat
building '/nix/store/06fi3aigs1wlbbbd3b4q6hfg7nly33ka-exa-0.8.0.drv'...
unpacking sources
unpacking source archive /nix/store/fqwsi5mhrl6568c1rfx1jl8vxnvbvnvz-source
source root is source
unpacking source archive /nix/store/7a21rfc96j21bwnlfkjsz5zd8nc2xw9j-exa-0.8.0-vendor
patching sources
updateAutotoolsGnuConfigScriptsPhase
configuring
building
Running cargo build --release 
   Compiling winapi-build v0.1.1
   Compiling libc v0.2.30
   Compiling num-traits v0.1.40
   Compiling rustc-serialize v0.3.24
   Compiling pkg-config v0.3.9
   Compiling gcc v0.3.53
   Compiling winapi v0.2.8
   Compiling matches v0.1.6
   Compiling unicode-normalization v0.1.5
   Compiling nom v1.2.4
   Compiling unicode-width v0.1.4
   Compiling percent-encoding v1.0.0
   Compiling utf8-ranges v0.1.3
   Compiling regex-syntax v0.3.9
   Compiling byteorder v0.4.2
   Compiling log v0.3.8
   Compiling bitflags v0.9.1
   Compiling getopts v0.2.14
   Compiling ansi_term v0.8.0
   Compiling lazy_static v0.2.8
   Compiling glob v0.2.11
   Compiling natord v1.0.9
   Compiling scoped_threadpool v0.1.7
   Compiling unicode-bidi v0.3.4
   Compiling kernel32-sys v0.2.2
   Compiling rand v0.3.16
   Compiling memchr v0.1.11
   Compiling locale v0.2.2
   Compiling users v0.5.3
   Compiling term_size v0.3.0
   Compiling num_cpus v1.6.2
   Compiling pad v0.1.4
   Compiling term_grid v0.1.6
   Compiling num-integer v0.1.35
   Compiling number_prefix v0.2.7
   Compiling iso8601 v0.1.1
   Compiling cmake v0.1.25
   Compiling libz-sys v1.0.16
   Compiling aho-corasick v0.5.3
   Compiling idna v0.1.4
   Compiling num-complex v0.1.40
   Compiling num-bigint v0.1.40
   Compiling num-iter v0.1.34
   Compiling thread-id v2.0.0
   Compiling thread_local v0.2.7
   Compiling regex v0.1.80
   Compiling libgit2-sys v0.6.14
   Compiling url v1.5.1
   Compiling num-rational v0.1.39
   Compiling num v0.1.40
   Compiling datetime v0.4.5
   Compiling zoneinfo_compiled v0.4.5
   Compiling env_logger v0.3.5
   Compiling git2 v0.6.8
   Compiling exa v0.8.0 (/tmp/nix-build-exa-0.8.0.drv-0/source)
warning: use of deprecated item 'std::ascii::AsciiExt': use inherent methods instead
  --> src/fs/file.rs:98:13
   |
98 |         use std::ascii::AsciiExt;
   |             ^^^^^^^^^^^^^^^^^^^^
   |
   = note: #[warn(deprecated)] on by default

warning: unused import: `std::ascii::AsciiExt`
  --> src/fs/file.rs:98:13
   |
98 |         use std::ascii::AsciiExt;
   |             ^^^^^^^^^^^^^^^^^^^^
   |
   = note: #[warn(unused_imports)] on by default

    Finished release [optimized] target(s) in 3m 50s
installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/k7j593q28g0w01xa0g5jnxm2fmm9877x-exa-0.8.0
gzipping man pages under /nix/store/k7j593q28g0w01xa0g5jnxm2fmm9877x-exa-0.8.0/share/man/
strip is /nix/store/5qj51mzplnxdfra88fxj7q0k5ki4r68a-binutils-2.31.1/bin/strip
patching script interpreter paths in /nix/store/k7j593q28g0w01xa0g5jnxm2fmm9877x-exa-0.8.0
checking for references to /data/data/com.termux.nix/files/usr/tmp/nix-build-exa-0.8.0.drv-0/ in /nix/store/k7j593q28g0w01xa0g5jnxm2fmm9877x-exa-0.8.0...
error (ignored): getting status of '/data/data/com.termux.nix/files/usr/tmp/nix-build-exa-0.8.0.drv-0/source/target/release/deps/exa-f09ef4abfab971d3': Operation not permitted
error: getting status of '/data/data/com.termux.nix/files/usr/tmp/nix-build-exa-0.8.0.drv-0/source/target/release/deps/exa-f09ef4abfab971d3': Operation not permitted

There are 76 unread and relevant news items.
Read them by running the command 'home-manager news'.

second home-manager run:

GC Warning: Couldn't read /proc/stat
GC Warning: Couldn't read /proc/stat
these derivations will be built:
  /nix/store/pqchpgln0fakk3qpqavim71la1617qzc-home-manager-path.drv
  /nix/store/hz5c6218yf1k6px4zb3xa6g02j10gd4m-activation-script.drv
  /nix/store/2175bk5bi1bv4lpldc4h9d5a2bkny7sy-home-manager-generation.drv
building '/nix/store/pqchpgln0fakk3qpqavim71la1617qzc-home-manager-path.drv'...
created 340 symlinks in user environment
building '/nix/store/hz5c6218yf1k6px4zb3xa6g02j10gd4m-activation-script.drv'...
building '/nix/store/2175bk5bi1bv4lpldc4h9d5a2bkny7sy-home-manager-generation.drv'...
/nix/store/4swy9x7p4fwagfv4hw4xfx6f7pi87sf8-home-manager-generation
Starting home manager activation
Activating checkFilesChanged
Activating checkLinkTargets
Activating writeBoundary
Activating installPackages
GC Warning: Couldn't read /proc/stat
replacing old 'home-manager-path'
installing 'home-manager-path'
building '/nix/store/04s3847cxrwm4i1yy2j973r0nl3121l5-user-environment.drv'...
created 6 symlinks in user environment
Activating linkGeneration
Cleaning up orphan links from /data/data/com.termux.nix/files/home
Creating profile generation 3
Creating home file links in /data/data/com.termux.nix/files/home
Activating onFilesChange
Activating reloadSystemD
User systemd daemon not running. Skipping reload.
Activating xdgCreateCache

There are 76 unread and relevant news items.
Read them by running the command 'home-manager news'.

Relicense under MIT?

@Gerschtli

Let's branch off the discussion here.

Las year, in a different repo altogether, I've started to bring Nix to Android. Back in the days, it was a Nix installation script heavily inspired by the official one, which I presumed to be authored by @edolstra and published under LGPL 2.1. Or at least I hope so, because it doesn't really come with a license header.

I thought that one day it could ship as part of a Nix, as a script to install it under Termux, so I kept the license.

Then I rewrote everything, going self-contained and Termux-free, installing through zipballs instead, but kept the license. Then you rewrote it, and kept the license.

If I were asked to trace it back to the original Nix script, I'd say that only these these two lines are what's lifted from the original install script and made it through the rewrites:

USER=${config.user.userName} ${prootCommand} "$PKG_NIX/bin/nix-store" --init
USER=${config.user.userName} ${prootCommand} "$PKG_NIX/bin/nix-store" --load-db < .reginfo

What we're heading towards today, for better or worse, is home-manager, nixos or nix-darwin territory. I would argue that this is small enough to be uncopyrightable, and those three projects already bear more similarity to nix-on-droid.

That said, how do you feel about relicensing the whole contents of this repo to MIT?

Support for termux addons and general questions about the intended scope of the project?

I want to begin by saying thanks for the project! I'm a big nixos fan and having it's features be available on android is quite nice. If you're curious I found the project after seeing your nixcon talk.

I'm wondering if it's inside the scope of the project to support some of the addons? More specifically termux-boot and termuxlauncher (which unfortunately has no licence so may have to be a clean room implementation (which may or may not take further inspiration from TUI) unless the creator sets a real licence.)

If you were willing to setup an organisation I'd be happy to put in some effort figuring it out myself. I'd also be interested in having a nix config for android, with the end goal of being able to carry around most of the state of an android system without root and playing by android's rules.

Init daemon to manage all running processes

Hey, in the last weeks I was trying to build service-like modules, e.g. an sshd service that will execute some commands before starting like generating a host key and start the sshd daemon. To stop it, you have to kill the process, which needs to be done on exiting the app, if not it will run in the background.

Similar problem with ssh-agent, the agent will not be killed on exiting the app.

Of course one could define for these commands services and let login-inner stop all running services on app exit, but this is not really error-prone.

That is why I thought of something like an init daemon, so that all processes started will be killed, when killing the init daemon.

Thats all I have for now. What do you thing? Have you another/a better idea?

Unable to install (64-bit)

Installation of bootstrap zipball fails on the first stage, during downloading. According to the traffic data, it downloads around 5 KB, then stops with the brief pop-up message about error.
My tablet with MT8735A definitely 64-bit and fit to launch Nix - I had a fully working installation with nix-in-termux script.
How do I fix this problem or at least collect more information about it?

Tightvnc vncserver: couldn't find "Xvnc" on your PATH

I have installed nixpkgs.xorg, nixpkgs.xwaayland, nixpkgs.openbox and nixpkgs-unstable.tightvnc, and export DISPLAY=":1" but get

bash-4.4$ vncserver -localhosh
perl: warning: Setting locale failed.       perl: warning: Please check that your locale settings:                                          LANGUAGE = (unset),                         LC_ALL = (unset),                           LANG = "en_US.UTF-8"                    are supported and installed on your system.                                         perl: warning: Falling back to the standard locale ("C").                               vncserver: couldn't find "Xvnc" on your PATH.

when running vncserver.
So I still have difficulty getting a gui.

fails to build ghc

I use nix-env -i ghc to install GHC. However, when compiling Distribution.SPDX.LIcenseId, I get the following error:

[123 of 270] Compiling Distribution.SPDX.LicenseId ( libraries/Cabal/Cabal/Distribution/SPDX/LicenseId.hs, bootstrapping/Distribution/SPDX/LicenseId.o )
utils/genprimopcode/ghc.mk:19: utils/genprimopcode/dist/package-data.mk: No such file or directory
make[1]: *** [utils/ghc-cabal/ghc.mk:56: utils/ghc-cabal/dist/build/tmp/ghc-cabal] Killed
make: *** [Makefile:123: all] Error 2
error (ignored): getting status of '/data/data/com.termux.nix/files/usr/tmp/nix-build-ghc-8.6.4.drv-1/ghc-8.6.4/utils/unlit/fs.c': Operation not permitted
error: cannot unlink '/data/data/com.termux.nix/files/usr/tmp/nix-build-ghc-8.6.4.drv-1/ghc-8.6.4/utils/fs': Directory not empty

I have no idea why this happens and whether it is related to Nix-on-droid or just to GHC.

Could you take some time to look into it when you are free? Thanks!

My android version is 7.1.1

Remove hardcoded paths in .login-inner and fixed links in /bin/sh and /usr/bin/env

Hello,

first of all I have to thank you for this great project!

I am using nix-on-droid a while now and ran nix-collect-garbage.. This resulted in dead links for /bin/sh and /usr/bin/env. Also the hardcoded paths in /bin/.login-inner were not present anymore.

I fixed it manually, but I think it would be much better, if these binaries are linked to ~/.nix-profile/bin on nix-on-droid-install. I would love to provide a PR for this, but unfortunately the instructions are not complete on how to convert the zip file to an installable apk.

Additionally I have two other questions (if these should be separate issues, I will move them out of here):

  • Is there any way to make /proc/stat readable? Would be useful for fixing the warnings when running nix-channel --update or to allow htop to work.
  • Is there any way to set the login shell? Currently when running tmux or similar, /bin/sh gets executed instead of my zsh shell.

no coreutils?

when i run home setup, it states its installed core utils

but i cannot use any coreutrils, grep, which, sed, etc are not found

and there is 0 documentation to speak of so can i please get some answers im trying to setup x11

Issues on OnePlus 6t

This is the error i get on oneplus 6t

Creating /etc/passwd...
sh: xmalloc: shell.c:1709: cannot allocate 43 bytes (0 bytes allocated)

[Process completed (code 2) - press Enter]

It's running Android 9 with oxygen 9.0.11

Build of `home-manager` failed with Bus error

Installing home-manager...
GC Warning: Couldn't read /proc/stat
GC Warning: Couldn't read /proc/stat
these derivations will be built:
/nix/store/6n2w6f1g3rsdrlwl1pbfnxpp9qwrqazb-home-manager.drv
GC Warning: Couldn't read /proc/stat
building '/nix/store/6n2w6f1g3rsdrlwl1pbfnxpp9qwrqazb-home-manager.drv'...
/nix/store/v262b100wnfjhyxjv5bk2zachznf3147-stdenv-linux/setup: line 1259: 24434 Bus error install -v -D -m755 /nix/store/3a2whifgkajbm618v1xx94j8llbm199a-home-manager $out/bin/home-manager
builder for '/nix/store/6n2w6f1g3rsdrlwl1pbfnxpp9qwrqazb-home-manager.drv' failed with exit code 135
error: build of '/nix/store/6n2w6f1g3rsdrlwl1pbfnxpp9qwrqazb-home-manager.drv' failed

ptrace on relevant line:

proot warning: ptrace request 'PTRACE_???' not supported yet
execve("/nix/store/cib5daqwbsbk6009r7pcpkd0snsf8brx-coreutils-8.30/bin/install", ["install", "/nix/store/3a2whifgkajbm618v1xx9"..., "/nix/store/szbfi2pknmdhr5xw5769k"...], 0x7fffffe540 /* 66 vars */) = 0
brk(NULL)                               = 0x561000
faccessat(AT_FDCWD, "/etc/ld-nix.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/tls/aarch64/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/tls/aarch64", 0x7fffffd5d0, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/tls/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/tls", 0x7fffffd5d0, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/aarch64/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/aarch64", 0x7fffffd5d0, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib", {st_mode=S_IFDIR|0555, st_size=4096, ...}, 0) = 0
openat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib/tls/aarch64/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib/tls/aarch64", 0x7fffffd5d0, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib/tls/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib/tls", 0x7fffffd5d0, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib/aarch64/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib/aarch64", 0x7fffffd5d0, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib", {st_mode=S_IFDIR|0555, st_size=4096, ...}, 0) = 0
openat(AT_FDCWD, "/nix/store/m6bmjrz6zqp95qaj2jimyqyq65azis8v-glibc-2.27/lib/tls/aarch64/librt.so.1", O
_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/m6bmjrz6zqp95qaj2jimyqyq65azis8v-glibc-2.27/lib/tls/aarch64", 0x7fffffd5d0, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/m6bmjrz6zqp95qaj2jimyqyq65azis8v-glibc-2.27/lib/tls/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/m6bmjrz6zqp95qaj2jimyqyq65azis8v-glibc-2.27/lib/tls", 0x7fffffd5d0, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/m6bmjrz6zqp95qaj2jimyqyq65azis8v-glibc-2.27/lib/aarch64/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/m6bmjrz6zqp95qaj2jimyqyq65azis8v-glibc-2.27/lib/aarch64", 0x7fffffd5d0, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/m6bmjrz6zqp95qaj2jimyqyq65azis8v-glibc-2.27/lib/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0000\36\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0555, st_size=37464, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb7ffd000
mmap(NULL, 90464, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb7fe6000
mprotect(0x7fb7fec000, 61440, PROT_NONE) = 0
mmap(0x7fb7ffb000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x5000) = 0x7fb7ffb000
close(3)                                = 0
openat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/m6bmjrz6zqp95qaj2jimyqyq65azis8v-glibc-2.27/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\360\\\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0555, st_size=138776, ...}) = 0
mmap(NULL, 180680, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb7fb9000
mprotect(0x7fb7fd0000, 65536, PROT_NONE) = 0
mmap(0x7fb7fe0000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17000) = 0x7fb7fe0000
mmap(0x7fb7fe2000, 12744, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fb7fe2000
close(3)                                = 0
openat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/libacl.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\0\37\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0555, st_size=38688, ...}) = 0
mmap(NULL, 94320, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb7fa1000
mprotect(0x7fb7fa8000, 61440, PROT_NONE) = 0
mmap(0x7fb7fb7000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7fb7fb7000
close(3)                                = 0
openat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/libattr.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib/libattr.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\240\27\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0555, st_size=23400, ...}) = 0
mmap(NULL, 81944, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb7f8c000
mprotect(0x7fb7f90000, 61440, PROT_NONE) = 0
mmap(0x7fb7f9f000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7fb7f9f000
close(3)                                = 0
openat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/m6bmjrz6zqp95qaj2jimyqyq65azis8v-glibc-2.27/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\350\10\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0555, st_size=1590536, ...}) = 0
mmap(NULL, 1377136, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb7e3b000
mprotect(0x7fb7f72000, 65536, PROT_NONE) = 0
mmap(0x7fb7f82000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x137000) = 0x7fb7f82000
mmap(0x7fb7f88000, 13168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fb7f88000
close(3)                                = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb7e39000
mprotect(0x7fb7f82000, 16384, PROT_READ) = 0
mprotect(0x7fb7f9f000, 4096, PROT_READ) = 0
mprotect(0x7fb7fb7000, 4096, PROT_READ) = 0
mprotect(0x7fb7fe0000, 4096, PROT_READ) = 0
mprotect(0x7fb7ffb000, 4096, PROT_READ) = 0
mprotect(0x53c000, 45056, PROT_READ)    = 0
mprotect(0x3f0002c000, 4096, PROT_READ) = 0
set_tid_address(0x7fb7e39750)           = 13268
set_robust_list(0x7fb7e39760, 24)       = -1 ENOSYS (Function not implemented)
rt_sigaction(SIGRTMIN, {sa_handler=0x7fb7fbe750, sa_mask=[], sa_flags=SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {sa_handler=0x7fb7fbe840, sa_mask=[], sa_flags=SA_RESTART|SA_SIGINFO}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
prctl(PR_SET_NAME, "install")           = 0
prctl(PR_SET_KEEPCAPS, 549755807983)    = -1 EINVAL (Invalid argument)
brk(NULL)                               = 0x561000
brk(0x582000)                           = 0x582000
geteuid()                               = 10099
umask(000)                              = 022
newfstatat(AT_FDCWD, "/nix/store/szbfi2pknmdhr5xw5769kir8lwwdg8b2-home-manager/bin/home-manager", 0x7fffffe2f8, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/3a2whifgkajbm618v1xx94j8llbm199a-home-manager", {st_mode=S_IFREG|0444, st_size=12499, ...}, 0) = 0
newfstatat(AT_FDCWD, "/nix/store/szbfi2pknmdhr5xw5769kir8lwwdg8b2-home-manager/bin/home-manager", 0x7fffffde48, AT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/3a2whifgkajbm618v1xx94j8llbm199a-home-manager", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0444, st_size=12499, ...}) = 0
openat(AT_FDCWD, "/nix/store/szbfi2pknmdhr5xw5769kir8lwwdg8b2-home-manager/bin/home-manager", O_WRONLY|O_CREAT|O_EXCL, 0600) = 4
fstat(4, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
fadvise64(3, 0, 0, POSIX_FADV_SEQUENTIAL) = 0
mmap(NULL, 139264, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb7e17000
read(3, "#!@bash@/bin/bash\n\n# Prepare to "..., 131072) = 12499
write(4, "#!@bash@/bin/bash\n\n# Prepare to "..., 12499) = 12499
read(3, "", 131072)                     = 0
fsetxattr(-95, "system.posix_acl_access", "\2\0\0\0\1\0\6\0\377\377\377\377\4\0\0\0\377\377\377\377 \0\0\0\377\377\377\377", 28, 0) = 4
fchmod(0, 0600)                         = 4
close(0)                                = 3
close(0)                                = 548545851392
munmap(NULL, 139264)                    = -1 ENETDOWN (Network is down)
fchmodat(-2, "/nix/store/szbfi2pknmdhr5xw5769kir8lwwdg8b2-home-manager/bin/home-manager", 0755 <unfinished ...>
--- SIGBUS {si_signo=SIGBUS, si_code=BUS_ADRALN, si_addr=0x7fb7e68008} ---
<... fchmodat resumed>)                 = ?
+++ killed by SIGBUS +++

Device: Xiaomi Redmi 4X, LineageOS 15.1-20181114-NIGHTLY-santoni

error: packages '/nix/store/yvr7hjdxj1b5jcjk3pgh9z4gmwn78lql-home-manager-path/etc/man_db.conf' and '/nix/store/naig9qc4bmx1gp4nmsmxwmnllx0cjlvc-nix-on-droid-path/etc/man_db.conf' have the same priority 5

Activating linkBinSh
Activating linkUsrBinEnv
Activating installLogin
Activating installLoginInner
Activating installPackages
GC Warning: Couldn't read /proc/stat
replacing old 'nix-on-droid-path'
installing 'nix-on-droid-path'
Activating installProotStatic
Activating setUpEtc
Activating homeManager
Starting home manager activation
GC Warning: Couldn't read /proc/stat
GC Warning: Couldn't read /proc/stat
Activating checkFilesChanged
Activating checkLinkTargets
Activating writeBoundary
Activating installPackages
GC Warning: Couldn't read /proc/stat
installing 'home-manager-path'
building '/nix/store/1w8d8qzqzcrfnbjk1879lg7abai7gznm-user-environment.drv'...
error: packages '/nix/store/yvr7hjdxj1b5jcjk3pgh9z4gmwn78lql-home-manager-path/etc/man_db.conf' and '/nix/store/naig9qc4bmx1gp4nmsmxwmnllx0cjlvc-nix-on-droid-path/etc/man_db.conf' have the same priority 5; use 'nix-env --set-flag priority NUMBER INSTALLED_PKGNAME' to change the priority of one of the conflicting packages (0 being the highest priority)
builder for '/nix/store/1w8d8qzqzcrfnbjk1879lg7abai7gznm-user-environment.drv' failed with exit code 1
error: build of '/nix/store/1w8d8qzqzcrfnbjk1879lg7abai7gznm-user-environment.drv' failed
  • system: "aarch64-linux"
  • host os: Linux 4.4.200-g122700c1790b
  • multi-user?: no
  • sandbox: no
  • version: nix-env (Nix) 2.3.5
  • channels(nix-on-droid): "home-manager-20.03, nix-on-droid-20.03, nixpkgs-20.03.2015.e7752db2fb6"
  • nixpkgs: /data/data/com.termux.nix/files/home/.nix-defexpr/channels/nixpkgs

Configure host name

Enable configuration of host name in nix-on-droid config.

I tried to achieve this with #45 but that didn't work.

home-manager like module system

Hey,

I want to come up with a solution for configuring nix-on-droid with or without home-manager. I came up with multiple solutions and want to hear your opinions about it, before I implement any of them.

I prototyped a minimal version, where I am able to set options in ~/.config/nixpkgs/config.nix like this:

{
  nix-on-droid = {
    # entry point for nix-on-droid module system
    test = "abc";
  };
}

Note: It's possible and my preferred option to define a separate config file like ~/.config/nixpkgs/nix-on-droid.nix. This way we get better error messages (prints path to file) and we have similar config files to the ones in nixos and home-manager. Example:

# entry point for nix-on-droid module system
{
  test = "abc";
}

The implementation of this module could look like this:

{ config, lib, pkgs, ... }:

with lib;

{
  options = {
    test = mkOption {
      type = types.str;
      default = "default value test";
      description = "Internal option";
    };

    test2 = mkOption {
      type = types.str;
      default = "default value test2";
      description = "Internal option2";
    };
  };

  config = {
    nix-on-droid.packages = [
      (pkgs.writeTextDir "testfile" ''
        test: ${config.test}
        test2: ${config.test2}
      '')
    ];
  };
}

With this way we could replace the static list of packages in default.nix in basic-environment with the merged nix-on-droid.packages list. The nix-on-droid-linker has to be called after every change and needs to remove old links.

Instead of the nix-on-droid.packages list and the fragile nix-on-droid-linker setup, we could provide an executable similar to home-manager script.

The only results of possible nix-on-droid options and configs I can think of is managing /data/data/com.termux.nix/files/usr directory. Therefore I recommend implementing something like environment.etc in nixos (https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/system/etc) for just this directory. This should be fairly easy to implement, provides atomic upgrades and removes old files. With this implementation we also don't need this basic-environment anymore.

Concerning the integration with home-manager, refactoring the home.file option for our case could be a possible solution but this would mean we have to support both ways which are conflicting a bit. The better solution would be, if we could inject our activation script logic (linking etc like environment.etc) in the one of home-manager, but currently there isn't any option. We would need something like that: nix-community/home-manager#779.

I would say it's save enough to try the custom module system and custom nix-on-droid activator script and ignore the home-manager integration for now. home-manager would still work perfectly fine with this solution, the user just has to manage to config files until we get a better solution.

What do you say?

android 10 min api deadline question

Hello,
I was wondering, will nixos/nix-on-droid be effected by the minimum sdk / android 10 issue (as termux will be) in a few months from now?

I am looking for a backup to termux, that won't end up broken when this api cutoff deadline occurs (in November 2020 I think). I am rooted and on a custom rom, if that makes any difference.

Really hope this will possibly be a good alternative, and if it's uneffected I wonder if the creator of this could figure out with the termux dev how to fix the issue (there gonna use apks instead of packages or something, sounds a bit messy). I know they were taking about using proot and other things like that, so maybe that could end up being a potential collaboration.. who knows :-)

Thanks!

Automate building and pushing packages with overlays?

As we recently introduced an overlay for htop and I think that there will be many overlays created in the future (see termux packages and their patches), we should think about a build environment which will push the built packages to cachix.

We could use aarch64 build machine like those provided by travis-ci or github workflow to build these packages. Or we could consider using a custom android phone as build machine via hercules-ci or github workflow self-hosted runner or anything with a matching architecture if there are any compatibility issues between aarch64 machines and the android/bionic env. Maybe there are other options to automate this.

In the htop overlay I pinned the nixpkgs version. This provides us with the possibility to update the pinned version, build and push all packages and only on success commit and push the new rev of the nixpkgs version. This could be easily automated with github workflow for example.

My main intention behind all of this is to prevent (re)builds on client devices but also to update the pinned nixpkgs version regularly to prevent outdated packages.

What do you think? Are there any problems I missed out?

Trying to grant access to external storage

$ nix run nixpkgs.nix-info -c nix-info -m

 - system: `"aarch64-linux"`
 - host os: `Linux 4.4.111-17594784`
 - multi-user?: `no`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.3.3`
 - channels(nix-on-droid): `"home-manager-19.09, nix-on-droid, nixpkgs-19.09.2213.71c6a1c4a83"`
 - nixpkgs: `/data/data/com.termux.nix/files/home/.nix-defexpr/channels/nixpkgs`

Hello,

nix-on-droid is just great and my favorite android app so far.
What I'm still trying to do is getting access to a folder outside for easily sharing configs and stuff:

But neither of the commands seems to be available.
I also gave the app storage permission.

emacs path.c assertion "length2 > 0" failed

Warning: no reproduction yet

[ ] - bisect packages to identify package triggering paths.c
[ ] - create minimal repro with emacs -Q

Using my quite large emacs config i get the following error.

./path/path.c:547: Comparison compare_paths2(const char *, size_t, const char *, size_t): assertion "length2 > 0" failed
  proot warning: signal 6 received from process 5597

Putting this here in this pre repro state in case others want to see state of emacs support or someone recognizes that error.

I'll debug this further as time allows.

Style settings can not be applied

Steps to reproduce

  • Install app-debug.apk
  • Style -> Choose Color -> Select any color
    Popup appears:
Failed to install file:

Application package com.termux not found
  • Install termux from Google Play (should I?)
  • Style -> Choose Color -> Select any color
    Popup appears:
Failed to install file:

Cannot create termux dir=/data/user/0/com.termux/files/home/.termux

TODO: change default login shell

Give the user the possibility to change the default shell. Changing the value in /etc/passwd is not enough, nix-on-droid-app needs to reads this value.

[Issue with the app itself] Shortcuts crash the app

Note: This is an issue probably with the app itself, but as the fork doesn't have issues open, I can't report it.

Shortcuts (termux-widget code) doesn't seem to work; Big widget crashes the app on click, small widget does nothing or opens the current Nix session.

DNS settings are not picked up from Android

Currently DNS servers are set to 1.1.1.1 and 8.8.8.8 and that will cause problems with networks that block them. DNS settings should be picked up from Android, ideally with VPN support and runtime changes. I have no idea how to implement this at the moment.

root certificates missing?

I got this message when I try to use niv:

image

I have cacert installed.

I also have a similar message when I try to push stuff to cachix.

Any ideas?

New to nix-on-droid

can I get commands detail as well as wiki to use this application

thanks in advance

TODO: custom home-manager module

We should provide a home-manager module to configure the installation.

Some values configurable through the home-manager installation could be user or group name. Furthermore we could write the files in /bin, /etc and /usr via home-manager and uninstall the basic-environment. That way we would not need to rely on the fragile nix-on-droid-linker thing.

nix-env -qa and nix search don't work

This is a fresh install from f-droid version 0.66_v0.2.2_nix, Android 7.1.2 LineageOS 14.1. The bootstrap installed fine.
For example nix-env -qa dnsutils returns error: selector 'dnsutils' matches no derivations
nix search dnsutils returns error: executing '': No such file or directory

Trying to open /data/data/com.termux.nix/files/usr/usr/lib/login-inner with a file manager returns a file not found error (tried with Amaze internal text editor and Quickedit).

remote builder (using qemu for aarch64)?

I think many packages need to be compiled on my phone when I update. I takes a while and use my battery.

Anyone uses a remote builder? I wonder how to set up a remote builder using qemu to build the aarch64 packages for android on my x86_64 machine.

ssh server

It'd be nice to be able to access the Nix/Termux shell remotely. Can you add instructions how to do so?
It's very easy on Termux, but simply installing nix-env -iA nixpkgs.openssh then running sshd doesn't work out of the box.
https://wiki.termux.com/wiki/Remote_Access

Reinstate locale hack

We've dropped

{
  # Fix locale (perl apps panic without it)
  home.sessionVariables = {
    LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
  };
}

This should be reinstated somehow somewhere.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.