Subject: [PATCH] gnu: wpa-supplicant: Install wpa_gui.
From: Marius Bakke <[email-masked]>
To: [email-masked]
Cc: Marius Bakke <[email-masked]>
Date: Sun, 8 Apr 2018 22:22:41 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

* gnu/packages/admin.scm (wpa-supplicant)[inputs]: Add QTBASE and QTSVG.
[native-inputs]: Add IMAGEMAGICK and INKSCAPE.
[outputs]: New field.
[arguments]: Add phases 'build-wpa-gui' and 'install-wpa-gui'.
---
 gnu/packages/admin.scm | 39 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 6a7bed389..8b64a531e 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -18,7 +18,7 @@
 ;;; Copyright © 2017 Ben Sturmfels <[email-masked]>
 ;;; Copyright © 2017 Ethan R. Jones <[email-masked]>
 ;;; Copyright © 2017 Christopher Allan Webber <[email-masked]>
-;;; Copyright © 2017 Marius Bakke <[email-masked]>
+;;; Copyright © 2017, 2018 Marius Bakke <[email-masked]>
 ;;; Copyright © 2018 Arun Isaac <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -68,6 +68,8 @@
   #:use-module (gnu packages bison)
   #:use-module (gnu packages flex)
   #:use-module (gnu packages glib)
+  #:use-module (gnu packages imagemagick)
+  #:use-module (gnu packages inkscape)
   #:use-module (gnu packages openldap)
   #:use-module (gnu packages mcrypt)
   #:use-module (gnu packages pkg-config)
@@ -75,6 +77,7 @@
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-crypto)
   #:use-module (gnu packages python-web)
+  #:use-module (gnu packages qt)
   #:use-module (gnu packages terminals)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages groff)
@@ -1110,7 +1113,15 @@ This package provides the 'wpa_supplicant' daemon and the 'wpa_cli' command.")
   (package (inherit wpa-supplicant-minimal)
     (name "wpa-supplicant")
     (inputs `(("dbus" ,dbus)
+              ("qtbase" ,qtbase)
+              ("qtsvg" ,qtsvg)
               ,@(package-inputs wpa-supplicant-minimal)))
+    (native-inputs
+     ;; For icons.
+     `(("imagemagick" ,imagemagick)
+       ("inkscape" ,inkscape)
+       ,@(package-native-inputs wpa-supplicant-minimal)))
+    (outputs '("out" "gui"))
     (arguments
      (substitute-keyword-arguments (package-arguments wpa-supplicant-minimal)
        ((#:phases phases)
@@ -1124,6 +1135,32 @@ This package provides the 'wpa_supplicant' daemon and the 'wpa_cli' command.")
       CONFIG_CTRL_IFACE_DBUS_INTRO=y\n" port)
                  (close-port port))
                #t))
+           (add-after 'build 'build-wpa-gui
+             (lambda _
+               (with-directory-excursion "wpa_gui-qt4"
+                 (invoke "qmake" "wpa_gui.pro")
+                 (invoke "make" "-j" (number->string (parallel-job-count)))
+                 (invoke "make" "-C" "icons"))))
+           (add-after 'install 'install-wpa-gui
+             (lambda* (#:key inputs outputs #:allow-other-keys)
+               (let ((gui (assoc-ref outputs "gui"))
+                     (qt '("qtbase" "qtsvg")))
+                 (with-directory-excursion "wpa_gui-qt4"
+                   (substitute* "wpa_gui.desktop"
+                     (("Exec=wpa_gui")
+                      (string-append "Exec=" gui "/bin/wpa_gui")))
+                   (install-file "wpa_gui" (string-append gui "/bin"))
+                   (install-file "wpa_gui.desktop"
+                                 (string-append gui "/share/applications"))
+                   (copy-recursively "icons/hicolor"
+                                     (string-append gui "/share/icons/hicolor"))
+                   (wrap-program (string-append gui "/bin/wpa_gui")
+                     `("QT_PLUGIN_PATH" ":" prefix
+                       ,(map (lambda (label)
+                               (string-append (assoc-ref inputs label)
+                                              "/lib/qt5/plugins/"))
+                             qt)))
+                   #t))))
           (add-after 'install-man-pages 'install-dbus-conf
             (lambda* (#:key outputs #:allow-other-keys)
               (let* ((out (assoc-ref outputs "out"))
-- 
2.17.0