at 25.11-pre 1.9 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8let 9 cfg = config.virtualisation.waydroid; 10 kCfg = config.lib.kernelConfig; 11 kernelPackages = config.boot.kernelPackages; 12 waydroidGbinderConf = pkgs.writeText "waydroid.conf" '' 13 [Protocol] 14 /dev/binder = aidl2 15 /dev/vndbinder = aidl2 16 /dev/hwbinder = hidl 17 18 [ServiceManager] 19 /dev/binder = aidl2 20 /dev/vndbinder = aidl2 21 /dev/hwbinder = hidl 22 ''; 23 24in 25{ 26 27 options.virtualisation.waydroid = { 28 enable = lib.mkEnableOption "Waydroid"; 29 }; 30 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"; 35 }; 36 37 system.requiredKernelConfig = [ 38 (kCfg.isEnabled "ANDROID_BINDER_IPC") 39 (kCfg.isEnabled "ANDROID_BINDERFS") 40 (kCfg.isEnabled "MEMFD_CREATE") 41 ]; 42 43 /* 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 47 */ 48 boot.kernelParams = [ "psi=1" ]; 49 50 environment.etc."gbinder.d/waydroid.conf".source = waydroidGbinderConf; 51 52 environment.systemPackages = with pkgs; [ waydroid ]; 53 54 networking.firewall.trustedInterfaces = [ "waydroid0" ]; 55 56 virtualisation.lxc.enable = true; 57 58 systemd.services.waydroid-container = { 59 description = "Waydroid Container"; 60 61 wantedBy = [ "multi-user.target" ]; 62 63 serviceConfig = { 64 Type = "dbus"; 65 UMask = "0022"; 66 ExecStart = "${pkgs.waydroid}/bin/waydroid -w container start"; 67 BusName = "id.waydro.Container"; 68 }; 69 }; 70 71 systemd.tmpfiles.rules = [ 72 "d /var/lib/misc 0755 root root -" # for dnsmasq.leases 73 ]; 74 75 services.dbus.packages = with pkgs; [ waydroid ]; 76 }; 77 78}