Conversation
3473040 to
eca7814
Compare
|
Good job (from a cursory inspection)! I will try these out during the weekend. |
|
After the fix to the postmarketos image everything works well for me (I'm on x86_64). But if fails to launch android apps from desktop files without anbox session-manager running in a terminal EDIT: Scratch that this might be due to my system setup to wipe /var every boot |
|
Ah, note that even on another attempt a year back Launching the first anbox app from a fresh boot/session may take some time, as it has to start the container too. Anbox assumes on a modern system it takes "up to 10 seconds". The assumption was changed to 100 seconds, similar to what postmarketOS does. |
eca7814 to
b084ab6
Compare
|
@cidkidnix can you also tell me the kernel version, and how you made |
I patched my nixpkgs with this PR, My kernel version is 5.11.21, and the above code snippet is what I have imported as a module to enable the kernel configs EDIT: The audio issue would be resolved with this PR for anbox anbox/anbox#1034 but it has yet to be merged and I don't know if it ever will |
|
I'll also be able to test on my pinephone sometime soon:tm: |
|
Looks like the patch for audio requires a fresh image build. So that wouldn't help AFAICT. It would be nice to see @danielfullmer's robotnix build the Anbox images, so that a more trustful environment can be built to run Anbox. |
|
Here's an example usage of the option for customizing the image. { pkgs, ... }:
{
virtualisation.anbox = {
enable = true;
image = pkgs.anbox-postmarketos-image;
# https://gitlab.com/postmarketOS/pmaports/-/blob/bf6ad7a78c5506eb5ad9089e87f9c1cf7e8cd1f8/main/anbox-image/APKBUILD#L39-63
imageModifications =
let
fdroid_apk = pkgs.fetchurl {
url = "https://f-droid.org/repo/org.fdroid.fdroid_1013000.apk";
sha256 = "1n5zcxsfn42b3i067pnkjy3xf5ljs0fj9h01v69xfincr84mlh0y";
};
fdroidpriv_apk = pkgs.fetchurl {
url = "https://f-droid.org/repo/org.fdroid.fdroid.privileged_2120.apk";
sha256 = "1axa72vfd8qq2dyk7d171vpwb6rf5ps59zrchhhgqmrqmpv88gww";
};
in
''
(PS4=" $ "; set -x
echo "Disabling su"
rm -v system/xbin/su
echo "Installing FDroid"
mkdir system/app/FDroid
mkdir system/priv-app/FDroid
cp "${fdroid_apk}" system/app/FDroid/${fdroid_apk.name}
cp "${fdroidpriv_apk}" system/priv-app/FDroid/${fdroidpriv_apk.name}
chmod 0644 system/app/FDroid/*
chmod 0644 system/priv-app/FDroid/*
)
'';
};
}Customised this way, the end-user does not need to install F-Droid themselves, and F-Droid does not require additional fiddling around to install apps. I personally do not think such things belong in Nixpkgs... Mainly because this uses some pre-built APKs... Maybe we could provide a common way to pre-install any APK? Though I see that as a future improvement. The basic foundations exists to give the end-users the ability to do what they want. |
|
Could we not make a script that runs once after anbox is run to |
Running once is... harder than it sounds. And doesn't handle removing apps. The best bet actually would be to force the desired apps at the system level just like F-Droid here. Though I wonder how things act once a system app is removed. What happens with its data? With a normal Android app uninstall, the data goes away too. Still, it's out of scope for these changes. The foundations are now here to work on more complex behaviours if desired. I do not intend to work on fully nix-ifying the Anbox system config, it'd be hard for not enough benefits. I think installing F-Droid here to allow you to then install apps you want, and have F-Droid managing updates is a good enough solution for what hopefully is a temporary problem. We don't want to rely on Android apps! |
|
A massive change will probably be needed when erfan's A10 anbox stuff for halium gets ready to use, but we can deal with that when it happens https://github.com/Anbox-halium |
|
To add on, when a system app is uninstalled all data should be removed, although that isn't always the case |
Works with setting
application-manager starts on 5.4
On 5.10 without kernel CONFIG_ANDROID options, anbox-application-manager window stays open for a minute, then exits. |
|
For some reason it is not mounting /dev/binderfs for me. I'm trying to figure out, but you could make it a mount unit required by the container-manager like here. https://github.com/NixOS/nixpkgs/pull/102341/files#diff-b05067fd6d27b2c89be023bde744ecaab904222a09a136d004f9e5c5148fe966R81-R87 |
|
I assume this is with e.g. 5.10 (lts) or the latest kernel.
EDIT: github scrolled me to the last comment... the first comment I sent was not in any way helpful |
|
Note that I don't know how this acts on 5.4 yet. I still need to get a "normal" computer that runs 5.4 nicely to test a bit with the anbox kernel modules. I assume it's possible |
Yes, that's to be expected. Nothing we can do if the kernel options are not enabled. They are features Anbox and Android uses. |
As noted in NixOS#102341 this is not actually running as a forked process. It only tells the process that it is running "as a daemon, so shut the warning up". See `daemon_` here - https://github.com/anbox/anbox/blob/9de4e87cdd05135e1c71e6eadb68bf82719cebdf/src/anbox/cmds/container_manager.cpp#L38-L79 It is **strictly** used to hide that message. Co-authored-by: Matt Votava <mvnetbiz@gmail.com>
The AArch64 image from anbox will not start.
c477bda to
fdf7b4b
Compare
|
Tested again, both images on x86_64 are working. |
|
I'll test but it seems anbox crashes for me when it's running in the background and restarts itself, temporarily(maybe?) causing my user to lose connection to systemd, started happening shortly after I enabled anbox |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/run-android-apps-in-nixos/14437/2 |
| ]; | ||
|
|
||
| patchPhase = '' | ||
| prePatch = '' |
There was a problem hiding this comment.
| prePatch = '' | |
| postPatch = '' |
otherwise patches no longer rapply.
|
@cidkidnix btw, anbox halium is at https://github.com/waydroid/anbox-halium |
|
The lxc patch seems to no longer be required in latest nixpkgs. |
|
Also relevant: #140200 |
|
Sorry if this is a very newbie question, but is there a way to try to this PR without bringing this commit into the channels nor replacing my whole nixpkgs by this -- i.e. just using the relevant packages and options from here? I know how to do that when it's just one package to add to |
|
Best just clone nixpkgs, merge this branch and then |
|
Aha! That's easy and nice, thank you @Atemu I didn't know I could just do |
|
@arximboldi I don't want to disrespect anybody's work but at this point you should probably try #141076 since waydroid is newer than anbox |
|
Merged this into a relatively recent 21.11 nixpkgs branch, removed the lxc patch as suggested by @alyssais and it seems to work. Is something other than a suggested change |
| squashfsTools | ||
| ]; | ||
| } '' | ||
| echo "→ Extracting Anbox root image..." |
There was a problem hiding this comment.
| echo "→ Extracting Anbox root image..." | |
| echo "-> Extracting Anbox root image..." |
we shouldn't use special unicode characters
| ${cfg.imageModifications} | ||
| ) | ||
|
|
||
| echo "→ Packing modified Anbox root image..." |
There was a problem hiding this comment.
| echo "→ Packing modified Anbox root image..." | |
| echo "-> Packing modified Anbox root image..." |
| url = imgroot + "/android-7.1.2_r39-anbox_x86_64-userdebug.img"; | ||
| sha256 = "16vmiz5al2r19wjpd44nagvz7d901ljxdms8gjp2w4xz1d91vzpm"; | ||
| }; | ||
| }.${stdenv.system} |
There was a problem hiding this comment.
Missing or throw unsupported system to eval on unsupported platforms.
I can't really help because I don't know kernels to well. |
|
The kernel stuff should be dropped anyways. It was necessary to support kernels <5.5 which we don't really need to anymore. |
|
Kernel config was added here: #145768 |
|
Continuation in #253146. |

Motivation for this change
Make anbox work.
Some changes, mainly geared towards making it work.
Technically some of the changes could be considered breaking... But anbox doesn't work at all currently. So it can't be more breaking than that.
The AArch64 image from anbox doesn't work on my system. Though the postmarketOS image works fine.
Outdated info about kernel config
Newer kernels will require this configuration to be set:
I do not know if we would prefer setting these as defaults. They're not modules, so it changes the way the kernel acts I guess.
Things done
sandboxinnix.confon non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"./result/bin/)Tested with:
To be done
Test on kernel with compatible anbox module (e.g. 5.4)Validate how it acts on 5.5+ when the kernel is configured "incorrectly"AdoptNo they reverted themlinux-zenpatches?Add "OSS" android-toolsandroid-tools: init at 31.0.0p1 #124992 already did it... I feel silly.useAnboxModulesanduseBinderFSoptions that defaults according to the current semantics of looking at the kernel version. (Mobile NixOS, and devices using vendor kernels may not fit the requirements, but will actually work.)TO ANYONE TESTING: Can you please include these informations:
ashmemandbinderfsavailable