diff mbox series

[bug#55903,v8,02/41] gnu: Add go-github-com-creack-pty.

Message ID 20220822061141.13876-2-paren@disroot.org
State New
Headers show
Series [bug#55903,v8,01/41] gnu: Add go-github-com-zenhack-go-notmuch. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

\( Aug. 22, 2022, 6:11 a.m. UTC
From: "(unmatched-parenthesis" <paren@disroot.org>

* gnu/packages/golang.scm (go-github-com-creack-pty): New variable.
* guix/build-system/go.scm (go-target): Add to exported variables.
---
 gnu/packages/golang.scm  | 47 ++++++++++++++++++++++++++++++++++++++++
 guix/build-system/go.scm |  1 +
 2 files changed, 48 insertions(+)
diff mbox series

Patch

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 7797c3971d..931b76a50b 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -9943,3 +9943,50 @@  (define-public go-github-com-zenhack-go-notmuch
      "The notmuch package provides a Go language binding to the notmuch
 email library.")
     (license license:gpl3+)))
+
+(define-public go-github-com-creack-pty
+  (package
+    (name "go-github-com-creack-pty")
+    (version "1.1.18")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/creack/pty")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "1qqhcgfym0napz8damj7dhfw28g2qn2f5h3lr93i0sxawq926yzc"))))
+    (build-system go-build-system)
+    (arguments
+     (list #:import-path "github.com/creack/pty"
+           #:modules '((ice-9 popen)
+                       (ice-9 textual-ports)
+                       (guix build go-build-system)
+                       (guix build utils))
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'regenerate-types
+                 (lambda* (#:key import-path #:allow-other-keys)
+                   ;; Generated files are included (ztypes_*). We need to remake
+                   ;; them with Cgo.
+                   (with-directory-excursion (string-append "src/" import-path)
+                     (let* ((go-arch
+                             #$(car (go-target
+                                     (or (%current-target-system)
+                                         (nix-system->gnu-triplet (%current-system))))))
+                            (file (string-append "ztypes_" go-arch ".go"))
+                            (pipe (open-input-pipe "go tool cgo -godefs types.go"))
+                            (text (get-string-all pipe)))
+                       (close-pipe pipe)
+                       (for-each delete-file
+                         (find-files (getcwd) (file-name-predicate
+                                               "ztypes_[a-zA-Z0-9_]+.go")))
+                       (call-with-output-file file
+                         (lambda (port)
+                           (display text port))))))))))
+    (home-page "https://github.com/creack/pty")
+    (synopsis "Pseudoterminal handling in Go")
+    (description
+     "The pty package provides functions for working with Unix pseudoterminals.")
+    (license license:expat)))
diff --git a/guix/build-system/go.scm b/guix/build-system/go.scm
index 5e0e5bbad3..9e5f972c84 100644
--- a/guix/build-system/go.scm
+++ b/guix/build-system/go.scm
@@ -38,6 +38,7 @@  (define-module (guix build-system go)
             go-build-system
 
             go-pseudo-version?
+            go-target
             go-version->git-ref))
 
 ;; Commentary: