Subject: Adding r-gtk2 and other packages for r-qda (RFC)

From: Pjotr Prins <[email-masked]>
Date: Tue, 11 Sep 2018 14:23:20 +0200

Attached a bunch of packages I wrote for RQDA. This is a particular
useful package because it depends on GTK2.  guix import cran is pretty
awesome - it got most of it right :).

One or two hacks in there to disable X11 tests. Anyone any comments on
how to enable X11 instead of having X-headless? And is this good
enough to submit to Guix otherwise? 

Pj.
diff --git a/gnu/packages/statistics.scm b/gnu/packages/statistics.scm
index 04979ff..1c913a5 100644
--- a/gnu/packages/statistics.scm
+++ b/gnu/packages/statistics.scm
@@ -5715,3 +5715,188 @@ Java package that provides routines for various statistical distributions.")
     ;; are under the GPLv3, which is a mistake.  The author confirmed in an
     ;; email that this whole project should be under GPLv2+.
     (license license:gpl2+)))
+
+(define-public r-rgtk2
+  (package
+   (name "r-rgtk2")
+   (version "2.20.35")
+   (source
+    (origin
+     (method url-fetch)
+     (uri (cran-uri "RGtk2" version))
+     (sha256
+      (base32
+       "17nxxhkk9jvcwfajbhs5kyrx00lx1irggfbq3l2gp28dvb1cn6z9"))))
+   (properties `((upstream-name . "RGtk2")))
+   (build-system r-build-system)
+   (inputs
+    `(("atk" ,atk)
+      ("cairo" ,cairo)
+      ("glib" ,glib)
+      ("gtk+" ,gtk+-2)
+      ("pango" ,pango)))
+   (native-inputs `(("pkg-config" ,pkg-config)))
+   (home-page "http://www.ggobi.org/rgtk2")
+   (synopsis "R Bindings for Gtk 2.8.0 and Above")
+   (description
+    "Facilities in the R language for programming graphical interfaces
+using Gtk, the Gimp Tool Kit.")
+   (license (list license:gpl2+ license:gpl3+))))
+
+(define-public r-cairodevice
+  (package
+   (name "r-cairodevice")
+   (version "2.25")
+   (source
+    (origin
+     (method url-fetch)
+     (uri (cran-uri "cairoDevice" version))
+     (sha256
+      (base32
+       "0qsg6niz6b67yiqp200mi894s615y2bp0vb2sc093l9x9bc2jvfj"))))
+   (properties `((upstream-name . "cairoDevice")))
+   (build-system r-build-system)
+   (inputs `(("cairo" ,cairo)
+             ("gtk+" ,gtk+-2)
+             ))
+   (native-inputs `(("pkg-config" ,pkg-config)))
+   (arguments
+    `(#:tests? #f ;; requires running X11
+      #:configure-flags (list "--no-build-vignettes" "--no-test-load")
+      ))
+   (home-page
+    "http://cran.r-project.org/web/packages/cairoDevice")
+   (synopsis
+    "Embeddable Cairo Graphics Device Driver")
+   (description
+    "This device uses Cairo and GTK to draw to the screen, file (png,
+svg, pdf, and ps) or memory (arbitrary GdkDrawable or Cairo context).
+The screen device may be embedded into RGtk2 interfaces and supports
+all interactive features of other graphics devices, including
+getGraphicsEvent().")
+   (license (list license:gpl2+ license:gpl3+))))
+
+(define-public r-gwidgets
+  (package
+   (name "r-gwidgets")
+   (version "0.0-54")
+   (source
+    (origin
+     (method url-fetch)
+     (uri (cran-uri "gWidgets" version))
+     (sha256
+      (base32
+       "13lbbbnmkvb559klgsnz0q27qlyv102xakb6yccxsxjw249hm8c2"))))
+   (properties `((upstream-name . "gWidgets")))
+   (build-system r-build-system)
+   (home-page
+    "https://r-forge.r-project.org/R/?group_id=761")
+   (synopsis
+    "gWidgets API for building toolkit-independent, interactive GUIs")
+   (description
+    "gWidgets provides a toolkit-independent API for building
+interactive GUIs.  At least one of the 'gWidgetsXXX packages', such as
+gWidgetstcltk, needs to be installed.  Some icons are on loan from the
+scigraphica project http://scigraphica.sourceforge.net.")
+   (license license:gpl2+)))
+
+(define-public r-gwidgetsrgtk2
+  (package
+   (name "r-gwidgetsrgtk2")
+   (version "0.0-86")
+   (source
+    (origin
+     (method url-fetch)
+     (uri (cran-uri "gWidgetsRGtk2" version))
+     (sha256
+      (base32
+       "0b1xqffbzxlaaaqf1vzfl0a7b6wnnslsp8v5fbxblv7w951rsc4m"))))
+   (properties `((upstream-name . "gWidgetsRGtk2")))
+   (build-system r-build-system)
+   (propagated-inputs
+    `(("r-cairodevice" ,r-cairodevice)
+      ("r-gwidgets" ,r-gwidgets)
+      ("r-rgtk2" ,r-rgtk2)))
+   (arguments
+    `(#:tests? #f ;; requires running X11
+      #:phases
+      (modify-phases %standard-phases
+                     ;; we patch out cairoDevice because it requires X11
+                     (add-before 'install 'patch-out-cairoDevice
+                                 (lambda _
+                                   (substitute* "DESCRIPTION"
+                                                ;; this got ignored by R (("LazyLoad: yes") "LazyLoad: no")
+                                                (("cairoDevice") "methods"))
+                                   (substitute* "NAMESPACE"
+                                                (("cairoDevice") "methods"))#t))
+                     (delete 'check))))
+   (home-page
+    "http://cran.r-project.org/web/packages/gWidgetsRGtk2")
+   (synopsis
+    "Toolkit Implementation of gWidgets for RGtk2")
+   (description
+    "Port of the gWidgets API to the RGtk2 toolkit.")
+   (license license:gpl2+)))
+
+(define-public r-igraph
+  (package
+   (name "r-igraph")
+   (version "1.2.2")
+   (source
+    (origin
+     (method url-fetch)
+     (uri (cran-uri "igraph" version))
+     (sha256
+      (base32
+       "1bggm7b8v3bh7q2589w26qvd7sgs69m4qiij7d0rbm0ykkgxm8lx"))))
+   (build-system r-build-system)
+   (inputs
+    `(("glpk" ,glpk)
+      ("gmp" ,gmp)
+      ("libxml2" ,libxml2)
+      ("zlib" ,zlib)))
+   (propagated-inputs
+    `(("r-magrittr" ,r-magrittr)
+      ("r-matrix" ,r-matrix)
+      ("r-pkgconfig" ,r-pkgconfig)))
+   (native-inputs `(("gfortran" ,gfortran)))
+   (home-page "http://igraph.org")
+   (synopsis "Network Analysis and Visualization")
+   (description
+    "Routines for simple graphs and network analysis.  It can handle large graphs very well and provides functions for generating random and regular graphs, graph visualization, centrality methods and much more.")
+   (license license:gpl2+)))
+
+
+(define-public r-rqda
+  (let ((commit "3cd9abbbde590e1bf9c602b427ebd49e43b6b71a")
+        (revision "0.3-1"))
+    (package
+     (name "r-rqda")
+     (version (string-append "0-" revision "." (string-take commit 9)))
+     (source (origin
+              (method git-fetch) ;; git checkout because there are no recent releases
+              (uri (git-reference
+                    (url "https://github.com/Ronggui/RQDA.git")
+                    (commit commit)))
+              (file-name (string-append name "-" version "-checkout"))
+              (sha256
+               (base32
+                "1s8ibwikmkdhvl5i0simmdh7pqn7ql1vc9d2kxam9f0k56kdpkhb"))))
+     (properties `((upstream-name . "RQDA")))
+     (build-system r-build-system)
+     (propagated-inputs
+      `(("r-dbi" ,r-dbi)
+        ("r-gwidgets" ,r-gwidgets)
+        ("r-gwidgetsrgtk2" ,r-gwidgetsrgtk2)
+        ("r-igraph" ,r-igraph)
+        ("r-rgtk2" ,r-rgtk2)
+        ("r-rsqlite" ,r-rsqlite)))
+     (home-page "http://rqda.r-forge.r-project.org")
+     (synopsis "Qualitative Data Analysis")
+     (description
+      "Software for qualitative text analysis (Kuckartz, 2014,
+<doi:10.4135/9781446288719>).  Current version only supports plain
+text, but it can import PDF highlights if package
+'rjpod' (<https://r-forge.r-project.org/projects/rqda/>) is
+installed.")
+     (license license:bsd-3))))