9 cfg = config.virtualisation.waydroid;
10 kCfg = config.lib.kernelConfig;
11 kernelPackages = config.boot.kernelPackages;
12 waydroidGbinderConf = pkgs.writeText "waydroid.conf" ''
15 /dev/vndbinder = aidl2
20 /dev/vndbinder = aidl2
27 options.virtualisation.waydroid = {
28 enable = lib.mkEnableOption "Waydroid";
31 config = lib.mkIf cfg.enable {
32 assertions = lib.singleton {
33 assertion = lib.versionAtLeast (lib.getVersion config.boot.kernelPackages.kernel) "4.18";
34 message = "Waydroid needs user namespace support to work properly";
37 system.requiredKernelConfig = [
38 (kCfg.isEnabled "ANDROID_BINDER_IPC")
39 (kCfg.isEnabled "ANDROID_BINDERFS")
40 (kCfg.isEnabled "MEMFD_CREATE")
44 NOTE: we always enable this flag even if CONFIG_PSI_DEFAULT_DISABLED is not on
45 as reading the kernel config is not always possible and on kernels where it's
46 already on it will be no-op
48 boot.kernelParams = [ "psi=1" ];
50 environment.etc."gbinder.d/waydroid.conf".source = waydroidGbinderConf;
52 environment.systemPackages = with pkgs; [ waydroid ];
54 networking.firewall.trustedInterfaces = [ "waydroid0" ];
56 virtualisation.lxc.enable = true;
58 systemd.services.waydroid-container = {
59 description = "Waydroid Container";
61 wantedBy = [ "multi-user.target" ];
66 ExecStart = "${pkgs.waydroid}/bin/waydroid -w container start";
67 BusName = "id.waydro.Container";
71 systemd.tmpfiles.rules = [
72 "d /var/lib/misc 0755 root root -" # for dnsmasq.leases
75 services.dbus.packages = with pkgs; [ waydroid ];