# golang.scm -rw-r--r-- 2.2 KiB View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
(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 format)
                       (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
                             (first
                              #$(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)))