Waydroid: Difference between revisions

Onny (talk | contribs)
Changing keyboard layout: Should be resolved upstream
Onny (talk | contribs)
 
(9 intermediate revisions by 2 users not shown)
Line 2: Line 2:


{{Warning|Waydroid requires a [[Wayland]] desktop session and cannot be used on X11 directly, but can be run in a nested [[Wayland]] session, using e.g. [https://www.hjdskes.nl/projects/cage cage].}}
{{Warning|Waydroid requires a [[Wayland]] desktop session and cannot be used on X11 directly, but can be run in a nested [[Wayland]] session, using e.g. [https://www.hjdskes.nl/projects/cage cage].}}
{{Warning|Installing Waydroid on your system before running nixos-generate-config will create unnecessary fstab entries that may interfere with system functionality.}}


== Installation ==
== Installation ==
{{Warning|Installing Waydroid on your system before running nixos-generate-config will create unnecessary fstab entries that may interfere with system functionality.}}


Enable Waydroid in your system configuration:
Enable Waydroid in your system configuration:
Line 12: Line 13:
   virtualisation.waydroid.enable = true;
   virtualisation.waydroid.enable = true;
   # Enable clipboard sharing
   # Enable clipboard sharing
   environment.systemPackages = [ pkgs.wp-clipboard ];
   environment.systemPackages = [ pkgs.wl-clipboard ];
}
}
</nowiki>}}
</nowiki>|name=|lang=}}




Line 31: Line 32:
== Usage ==
== Usage ==


Start the container
Start the container and userspace Wayland session. You'll know it is finished when you see the message "Android with user 0 is ready".


<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
Start the Waydroid LXC container
$ sudo systemctl start waydroid-container
$ sudo systemctl start waydroid-container
You'll know it worked by checking the journal You should see "Started Waydroid Container".
$ sudo journalctl -u waydroid-container -e
Start Waydroid session
You'll know it is finished when you see the message "Android with user 0 is ready".
$ waydroid session start
$ waydroid session start
</syntaxhighlight>
</syntaxhighlight>
Line 66: Line 60:
$ waydroid prop set persist.waydroid.width 608
$ waydroid prop set persist.waydroid.width 608
</syntaxhighlight>
</syntaxhighlight>
== Customization ==
=== Running applications that differ from the current host architecture via libhoudini or libndk<ref>Need help with activating libhoudini for waydroid on NixOS
https://www.reddit.com/r/NixOS/comments/15k2jxc/need_help_with_activating_libhoudini_for_waydroid/</ref> ===
Run <code>nix shell github:nix-community/NUR#repos.ataraxiasjel.waydroid-script -c sudo waydroid-script</code>
Or, alternatively, add <code>nur.repos.ataraxiasjel.waydroid-script</code> from the NUR to your flake or shell or NixOS <code>environment.systemPackages</code>, or HM <code>home.packages</code> or something like that based on [https://github.com/nix-community/NUR readme] and run <code>sudo waydroid-script</code>
In the TUI, select Android 13 > Install > libhoudini (or libndk, [https://github.com/casualsnek/waydroid_script/blob/fcb15624db0811615ea9800837a836c4777674bf/README.md#install-libndk-arm-translation which script author claims may be faster on AMD])


== Maintenance  ==
== Maintenance  ==
Line 105: Line 87:


=== Mount host directories ===
=== Mount host directories ===
{{Warning|Parts of this instruction will only work with the latest waydroid-helper package in NixOS master and will be available with the next release 25.11}}Install and configure graphical application <code>waydroid-helper</code><syntaxhighlight lang="nix">
 
Install and configure graphical application <code>waydroid-helper</code><syntaxhighlight lang="nix">
environment.systemPackages =  [ pkgs.waydroid-helper ];
environment.systemPackages =  [ pkgs.waydroid-helper ];


Line 118: Line 101:


=== GPS/Location forwarding ===
=== GPS/Location forwarding ===
First enable ''geoclue2'' and ''adb'' daemon on the host<syntaxhighlight lang="nix">
First enable ''geoclue2'' and ''adb'' daemon on the host<syntaxhighlight lang="nix">
services.geoclue2.enable = true;
services.geoclue2.enable = true;
Line 133: Line 117:
</syntaxhighlight>
</syntaxhighlight>


=== Notification forwarding ===
=== V4L2 camera forwarding ===
To forward notifications from the Waydroid container to the host system, [[KDE Connect]] can be used.
 
Camera forwarding using V4L2 is broken on upstream, but can be achieved by using the Waydroid images of the [https://github.com/WayDroid-ATV Waydroid-ATV project]. Further we also need an unstable Waydroid version (>1.6.2) for running it.<syntaxhighlight lang="nix">
disabledModules = [
  "virtualisation/waydroid.nix"
];
imports = [
"${inputs.nixpkgs-unstable}/nixos/modules/virtualisation/waydroid.nix"
];
 
nixpkgs.overlays = [
  (self: super: {
    waydroid = (inputs.nixpkgs-unstable.legacyPackages.x86_64-linux.waydroid.overrideAttrs (old: rec {
      version = "0-unstable-2026-04-26";
      src = pkgs.fetchFromGitHub {
        owner = "waydroid";
        repo = "waydroid";
        rev = "9478d59ad5c83b22478594e73d5879b93200fcb2";
        hash = "sha256-L4qU5TSWavxvyPUqVV00NCd0YZqAaKPWTe3dR/q15LE=";
      };
    }));
  })
];
</syntaxhighlight>You might [[Waydroid#Resetting Android Container|need to reset]] your existing Waydroid environment. Then stop the container and fetch the latest Waydroid-ATV images.<syntaxhighlight lang="bash">
systemctl stop waydroid-container
waydroid init -f \
  -c https://waydroid-atv.github.io/ota/a16-qpr2/system \
  -v https://waydroid-atv.github.io/ota/a16-qpr2/vendor \
  -r lineage \
  -s GAPPS
systemctl start waydroid-container
waydroid session start
 
</syntaxhighlight>In case the graphical interface wont show up or the setup wizard fails you can do<syntaxhighlight lang="bash">
waydroid shell -- am start -a android.intent.action.MAIN -c android.intent.category.HOME 
waydroid shell -- pm disable-user --user 0 com.google.android.setupwizard
waydroid shell -- pm disable-user --user 0 com.google.android.gms.setup
</syntaxhighlight>In case the camera access will crash the Waydroid container, there's a recent image which solves this on AMD GPUs. Download it and extract the contents to <code>/etc/waydroid-extra/images</code>. After that recreate the environment as mentioned above but only issue <code>waydroid init -f</code>.
 
=== Running applications that differ from the current host architecture via libhoudini or libndk<ref>Need help with activating libhoudini for waydroid on NixOS
 
https://www.reddit.com/r/NixOS/comments/15k2jxc/need_help_with_activating_libhoudini_for_waydroid/</ref> ===


On a Gnome-desktop, add following to your system config and enable:<syntaxhighlight lang="nix">
Run <code>nix shell github:nix-community/NUR#repos.ataraxiasjel.waydroid-script -c sudo waydroid-script</code>
programs.kdeconnect = {
  enable = true;
  package = pkgs.gnomeExtensions.gsconnect;
};
</syntaxhighlight>Open the application ''Extensions'' and enable ''Gsconnect'' plugin there.


Inside the Waydroid container, follow these steps:
Or, alternatively, add <code>nur.repos.ataraxiasjel.waydroid-script</code> from the NUR to your flake or shell or NixOS <code>environment.systemPackages</code>, or HM <code>home.packages</code> or something like that based on [https://github.com/nix-community/NUR readme] and run <code>sudo waydroid-script</code>


* Download and install the [https://f-droid.org/en/packages/org.kde.kdeconnect_tp/ KDE Connect app]
In the TUI, select Android 13 > Install > libhoudini (or libndk, [https://github.com/casualsnek/waydroid_script/blob/fcb15624db0811615ea9800837a836c4777674bf/README.md#install-libndk-arm-translation which script author claims may be faster on AMD])
* Open the app and and start pairing with the host machine
* You'll have to enable access to notifications by clicking on the corresponding entry in the permissions list inside the app
* If you get the system message "''Restricted setting / For your security, this setting is currently unavailable''", you'll have to enable restricted settings. Go to Android settings app, in the apps list select KDE connect and click in the upper right corner on the three dot menu to ''Allow restricted settings''
* You may have to reboot the Waydroid container for notification forward to work.


== Troubleshooting ==
== Troubleshooting ==
Line 160: Line 175:
ro.hardware.egl=swiftshader
ro.hardware.egl=swiftshader
</nowiki>}}
</nowiki>}}
=== Waydroid interferes with suspend/hybernation ===
According to [https://github.com/waydroid/waydroid/issues/168 an upstream issue], Waydroid might interfere with suspend or hybernation. You might have to stop the Android session and container to suspend your machine correctly.


==See Also:==
==See Also:==


* [https://wiki.archlinux.org/title/Waydroid Waydroid article on the Archlinux Wiki]
* [https://wiki.archlinux.org/title/Waydroid Waydroid article on the Archlinux Wiki]