Subject: [PATCH 4/4] gnu: Add waydroid.

From: phodina <[email-masked]>
Date: Wed, 10 Nov 2021 01:39:04 +0000

* gnu/packages/virtualization.scm (waydroid): New variable.

diff --git a/gnu/packages/virtualization.scm b/gnu/packages/virtualization.scm
index 1817f6dc22..d47d8402f6 100644
--- a/gnu/packages/virtualization.scm
+++ b/gnu/packages/virtualization.scm
@@ -2005,6 +2005,72 @@ (define-public bochs
 DOS or Microsoft Windows.")
     (license license:lgpl2.0+)))

+(define-public waydroid
+  (package
+    (name "waydroid")
+    (version "1.2.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/waydroid/waydroid")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "03d87sh443kn0j2mpih1g909khkx3wgb04h605f9jhd0znskkbmw"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (delete 'build)                ; no setup.py
+         (delete 'check)                ; no test suite
+         (replace 'install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (lib (string-append out "/lib/waydroid"))
+                    (tools (string-append lib "/tools"))
+                    (data (string-append lib "/data"))
+                    (apps (string-append out "/share/applications"))
+                    (bin (string-append out "/bin"))
+                    (site (string-append out "/lib/python"
+                                         ,(version-major+minor
+                                           (package-version python))
+                                         "/site-packages"))
+                    (path (getenv "PYTHONPATH")))
+               (mkdir-p tools)
+               (mkdir-p data)
+               (mkdir-p apps)
+               (mkdir-p bin)
+               (copy-recursively "tools" tools)
+               (copy-recursively "data" data)
+               (install-file (string-append data "/Waydroid.desktop")
+                             (string-append apps))
+               (substitute* (string-append apps "/Waydroid.desktop")
+                 (("/usr") lib))
+               (install-file "waydroid.py" lib)
+               (symlink (string-append lib "/waydroid.py") (string-append bin
+                                                                          "/waydroid.py"))
+               (wrap-program (string-append bin "/waydroid.py")
+                 `("PYTHONPATH" ":" prefix (,site ,path)))))))))
+    (inputs `(("bash-minimal" ,bash-minimal)
+              ("dnsmasq" ,dnsmasq)
+              ("libgbinder" ,libgbinder)
+              ("lxc" ,lxc)
+              ("nftables" ,nftables)
+              ("python" ,python)
+              ("python-gbinder" ,python-gbinder)
+              ("python-pygobject" ,python-pygobject)))
+    (home-page "https://waydro.id")
+    (synopsis "Container-based approach to boot a full Android system")
+    (description "Waydroid uses Linux namespaces @code{(user, pid, uts, net,
+mount, ipc)} to run a full Android system in a container and provide Android
+applications.  The Android inside the container has direct access to needed
+underlying hardware.  The Android runtime environment ships with a minimal
+customized Android system image based on LineageOS.  The used image is
+currently based on Android 10.")
+    (license license:gpl3)))
+
 (define-public xen
   (package
     (name "xen")
--
2.33.1