Subject: [PATCH] gnu: android: Add android-udev-rules package.
From: Maxim Cournoyer <[email-masked]>
To: guix-patches <[email-masked]>
Date: Fri, 29 Sep 2017 12:09:32 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello!

This new package should make it easy for anyone to properly use adb
or the (not yet packaged fastboot) Android command line tools as a
user (rather than root).

It can be used directly in the rules list of the udev service to extend it.

From ea637a7b5adb5f88cb6dc62759f25e36c1ea1acf Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Fri, 29 Sep 2017 09:17:03 -0400
Subject: [PATCH] gnu: android: Add android-udev-rules package.

* gnu/packages/android.scm (android-udev-rules): Add package.
---
 gnu/packages/android.scm | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/gnu/packages/android.scm b/gnu/packages/android.scm
index be3f50add..bff6a6038 100644
--- a/gnu/packages/android.scm
+++ b/gnu/packages/android.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2016 Marius Bakke <[email-masked]>
 ;;; Copyright © 2017 Julien Lepiller <[email-masked]>
 ;;; Copyright © 2017 Hartmut Goebel <[email-masked]>
+;;; Copyright © 2017 Maxim Cournoyer <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -21,10 +22,12 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages android)
+  #:use-module (guix gexp)
   #:use-module (guix packages)
   #:use-module (guix git-download)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system python)
+  #:use-module (guix build-system trivial)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (gnu packages)
   #:use-module (gnu packages gnupg)
@@ -305,6 +308,40 @@ of device actions, such as installing and debugging apps, and it provides access
 to a Unix shell that can run commands on the connected device or emulator.")
     (license license:asl2.0)))
 
+(define-public android-udev-rules
+  (package
+    (name "android-udev-rules")
+    (version "20170910")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/M0Rf30/android-udev-rules")
+             (commit version)))
+       (file-name (string-append name "-" version "-checkout"))
+       (sha256
+        (base32 "0vic40n3si0dxag3dyc3hi3pn7cjpm5q378x8v2ys19n3iz9fp1g"))))
+    (build-system trivial-build-system)
+    (native-inputs `(("source" ,source)))
+    (arguments
+     '(#:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils))
+         (let ((source (assoc-ref %build-inputs "source")))
+           (install-file (string-append source "/51-android.rules")
+                         (string-append %output "/lib/udev/rules.d"))))))
+    (home-page "https://github.com/M0Rf30/android-udev-rules")
+    (synopsis "udev rules for Android devices")
+    (description "Provides a set of udev rules to allow using Android devices
+with tools such as @command{adb} and @command{fastboot} without root
+privileges.  This package is intended to be added as a rule to the
+@code{udev-service-type} in your @code{operating-system}
+configuration. Additionally, an @code{adbusers} group must be defined and your
+user added to it.  @emph{Simply installing this package will @strong{not} have
+an effect.}")
+    (license license:gpl3+)))
+
 (define-public git-repo
   (package
     (name "git-repo")
-- 
2.14.1

Here's a sample config that demonstrates how it can be used (pay
attention to the definition of the adbusers group).

Thank you,

Maxim