Subject: [bug#48729] [PATCH v2 35/47] gnu: Add go-github-com-gotk3-gotk3.

From: Raghav Gururajan <[email-masked]>
Date: Thu, 3 Jun 2021 06:44:55 -0400

* gnu/packages/goloang.scm (go-github-com-gotk3-gotk3): New variable.

Co-authored-by: Jorge Gomez <[email-masked]>
---
 gnu/packages/golang.scm | 110 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 110 insertions(+)

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index e9611b6f67..ad0ba57b78 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -68,9 +68,119 @@
   #:use-module (gnu packages textutils)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages web)
+  #:use-module (gnu packages xorg)
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-1))
 
+(define-public go-github-com-gotk3-gotk3
+  (package
+    (name "go-github-com-gotk3-gotk3")
+    (version "0.5.2")
+    (source
+     (origin
+       (method git-fetch)
+       (uri
+        (git-reference
+         (url "https://github.com/gotk3/gotk3")
+         (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1d5b4nrf4fwdwv0w2h7m0jh65fcvm3xmjv3aypylzaa4fg8wi4cc"))))
+    (build-system go-build-system)
+    (arguments
+     `(#:unpack-path "github.com/gotk3/gotk3"
+       #:phases
+       (modify-phases %standard-phases
+         (replace 'build
+           (lambda* (#:key source system outputs search-paths build-flags unpack-path inputs #:allow-other-keys)
+             (for-each
+              (lambda (directory)
+                ((assoc-ref %standard-phases 'build)
+                 #:source source
+                 #:system system
+                 #:outputs outputs
+                 #:search-paths search-paths
+                 #:build-flags build-flags
+                 #:unpack-path unpack-path
+                 #:inputs inputs
+                 #:import-path directory))
+              (list
+               "github.com/gotk3/gotk3/cairo"
+               "github.com/gotk3/gotk3/gdk"
+               "github.com/gotk3/gotk3/gio"
+               "github.com/gotk3/gotk3/glib"
+               "github.com/gotk3/gotk3/gtk"
+               "github.com/gotk3/gotk3/pango"))
+             #t))
+         (add-before 'check 'pre-check
+           (lambda _
+             ;; Tests require a running X server.
+             (system "Xvfb :1 +extension GLX &")
+             (setenv "DISPLAY" ":1")
+             ;; Tests write to $HOME.
+             (setenv "HOME" (getcwd))
+             ;; Tests look for $XDG_RUNTIME_DIR.
+             (setenv "XDG_RUNTIME_DIR" (getcwd))
+             ;; For missing '/etc/machine-id'.
+             (setenv "DBUS_FATAL_WARNINGS" "0")
+             #t))
+         (replace 'check
+           (lambda* (#:key source system outputs search-paths tests? unpack-path inputs #:allow-other-keys)
+             (for-each
+              (lambda (directory)
+                ((assoc-ref %standard-phases 'check)
+                 #:source source
+                 #:system system
+                 #:outputs outputs
+                 #:search-paths search-paths
+                 #:tests? tests?
+                 #:unpack-path unpack-path
+                 #:inputs inputs
+                 #:import-path directory))
+              (list
+               "github.com/gotk3/gotk3/cairo"
+               "github.com/gotk3/gotk3/gdk"
+               "github.com/gotk3/gotk3/gio"
+               "github.com/gotk3/gotk3/glib"
+               "github.com/gotk3/gotk3/gtk"
+               "github.com/gotk3/gotk3/pango"))
+             #t))
+         (replace 'install
+           (lambda* (#:key source system outputs search-paths install-source? unpack-path inputs #:allow-other-keys)
+             (for-each
+              (lambda (directory)
+                ((assoc-ref %standard-phases 'install)
+                 #:source source
+                 #:system system
+                 #:outputs outputs
+                 #:search-paths search-paths
+                 #:install-source? install-source?
+                 #:unpack-path unpack-path
+                 #:inputs inputs
+                 #:import-path directory))
+              (list
+               "github.com/gotk3/gotk3/cairo"
+               "github.com/gotk3/gotk3/gdk"
+               "github.com/gotk3/gotk3/gio"
+               "github.com/gotk3/gotk3/glib"
+               "github.com/gotk3/gotk3/gtk"
+               "github.com/gotk3/gotk3/pango"))
+             #t)))))
+    (native-inputs
+     `(("glib:bin" ,glib "bin")
+       ("gtk+:bin" ,gtk+ "bin")
+       ("pkg-config" ,pkg-config)
+       ("xorg-server" ,xorg-server-for-tests)))
+    (inputs
+     `(("cairo" ,cairo)
+       ("glib" ,glib)
+       ("gtk+" ,gtk+)
+       ("pango" ,pango)))
+    (home-page "https://github.com/gotk3/gotk3")
+    (synopsis "Go bindings for GTK3")
+    (description "Gotk3 provides Go bindings for GTK 3 and dependent projects.")
+    (license license:isc)))
+
 (define-public go-github-com-getlantern-systray
   (package
     (name "go-github-com-getlantern-systray")
-- 
2.31.1