1 { config, lib, pkgs, ... }:
7 cfg = config.virtualisation.waydroid;
8 kernelPackages = config.boot.kernelPackages;
9 waydroidGbinderConf = pkgs.writeText "waydroid.conf" ''
12 /dev/vndbinder = aidl2
17 /dev/vndbinder = aidl2
24 options.virtualisation.waydroid = {
25 enable = mkEnableOption (lib.mdDoc "Waydroid");
28 config = mkIf cfg.enable {
29 assertions = singleton {
30 assertion = versionAtLeast (getVersion config.boot.kernelPackages.kernel) "4.18";
31 message = "Waydroid needs user namespace support to work properly";
34 system.requiredKernelConfig = with config.lib.kernelConfig; [
35 (isEnabled "ANDROID_BINDER_IPC")
36 (isEnabled "ANDROID_BINDERFS")
37 (isEnabled "ASHMEM") # FIXME Needs memfd support instead on Linux 5.18 and waydroid 1.2.1
40 /* NOTE: we always enable this flag even if CONFIG_PSI_DEFAULT_DISABLED is not on
41 as reading the kernel config is not always possible and on kernels where it's
42 already on it will be no-op
44 boot.kernelParams = [ "psi=1" ];
46 environment.etc."gbinder.d/waydroid.conf".source = waydroidGbinderConf;
48 environment.systemPackages = with pkgs; [ waydroid ];
50 networking.firewall.trustedInterfaces = [ "waydroid0" ];
52 virtualisation.lxc.enable = true;
54 systemd.services.waydroid-container = {
55 description = "Waydroid Container";
57 wantedBy = [ "multi-user.target" ];
60 ExecStart = "${pkgs.waydroid}/bin/waydroid -w container start";
61 ExecStop = "${pkgs.waydroid}/bin/waydroid container stop";
62 ExecStopPost = "${pkgs.waydroid}/bin/waydroid session stop";
66 systemd.tmpfiles.rules = [
67 "d /var/lib/misc 0755 root root -" # for dnsmasq.leases