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