aboutsummaryrefslogtreecommitdiff
path: root/gn/packages/guile.scm
blob: 08810e5266b4f4b67d24dd2d89cccadd680282cc (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
(define-module (gn packages guile)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix gexp)
  #:use-module (guix packages)
  #:use-module (guix git-download)
  #:use-module (guix build-system guile)
  #:use-module (guix build-system gnu)
  #:use-module ((gnu packages autotools) #:select (libltdl autoconf automake libtool))
  #:use-module ((gnu packages databases) #:select (mariadb))
  #:use-module ((gnu packages compression) #:select (zlib))
  #:use-module ((gnu packages perl) #:select (perl))
  #:use-module ((gnu packages texinfo) #:select (texinfo))
  #:use-module (guix utils)
  #:use-module (gnu packages build-tools)
  #:use-module (gnu packages package-management)
  #:use-module ((gnu packages bash) #:select (bash-minimal))
  #:use-module ((gnu packages bioinformatics) #:select (gemma))
  #:use-module ((gnu packages certs) #:select (nss-certs))
  #:use-module ((gnu packages guile) #:select (guile-json-4 guile-3.0 guile-2.2 guile-readline))
  #:use-module ((gnu packages guile-xyz) #:select (guile-dbi guile-dbd-mysql guile-fibers guile-redis guile-hashing guile-commonmark))
  #:use-module ((gnu packages parallel) #:select (parallel))
  #:use-module ((gnu packages perl) #:select (perl))
  #:use-module ((gnu packages tls) #:select (guile-gnutls openssl)))

(define %default-gnu-imported-modules
  (if (defined? '%default-gnu-imported-modules)
      %default-gnu-imported-modules
      '((guix build gnu-build-system)
        (guix build utils)
        (guix build gremlin)
        (guix elf))))

;; Lifted from:
;; https://lists.gnu.org/archive/html/artanis/2023-03/txtNk7zz7rJAN.txt
(define-public guile3-dbi
  (package
    (name "guile3-dbi")
    (version "2.1.8")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/opencog/guile-dbi")
                    (commit (string-append "guile-dbi-" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "123m4j82bi60s1v95pjh4djb7bh6zdwmljbpyg7zq8ni2gyal7lw"))))
    (build-system gnu-build-system)
    (arguments
     `(#:modules (((guix build guile-build-system)
                   #:select (target-guile-effective-version))
                  ,@%gnu-build-system-modules)
       #:imported-modules ((guix build guile-build-system)
                           ,@%gnu-build-system-modules)
       #:configure-flags
       (list (string-append
              "--with-guile-site-dir=" %output "/share/guile/site/"
              (target-guile-effective-version (assoc-ref %build-inputs "guile"))))
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'chdir
           (lambda _
             ;; The upstream Git repository contains all the code, so change
             ;; to the directory specific to guile-dbi.
             (chdir "guile-dbi")))
         (add-after 'install 'patch-extension-path
           (lambda* (#:key inputs outputs #:allow-other-keys)
             (let* ((out (assoc-ref outputs "out"))
                    (dbi.scm (string-append out "/share/guile/site/"
                                            (target-guile-effective-version
                                             (assoc-ref inputs "guile"))
                                            "/dbi/dbi.scm"))
                    (ext (string-append out "/lib/libguile-dbi")))
               (substitute* dbi.scm (("libguile-dbi") ext))))))))
    (inputs
     (list libltdl))
    (native-inputs
     (list autoconf automake libtool perl texinfo guile-3.0))
    (synopsis "Guile database abstraction layer")
    (home-page "https://github.com/opencog/guile-dbi")
    (description
     "guile-dbi is a library for Guile that provides a convenient interface to
SQL databases.  Database programming with guile-dbi is generic in that the same
programming interface is presented regardless of which database system is used.
It currently supports MySQL, Postgres and SQLite3.")
    (license license:gpl2+)
    (native-search-paths
     (list (search-path-specification
            (variable "GUILE_DBD_PATH")
            (files '("lib")))))))

(define-public guile3-dbd-mysql
  (package
    (inherit guile3-dbi)
    (name "guile3-dbd-mysql")
    (arguments
     (substitute-keyword-arguments (package-arguments guile3-dbi)
       ((#:phases phases)
        `(modify-phases ,phases
           (replace 'chdir
             (lambda _
               ;; The upstream Git repository contains all the code, so change
               ;; to the directory specific to guile-dbd-mysql.
               (chdir "guile-dbd-mysql")))
           (add-after 'chdir 'patch-src
             (lambda _
               (substitute* "configure.ac"
                 (("mariadbclient") "mariadb"))
               (substitute* "src/guile-dbd-mysql.c"
                 (("<mariadb/") "<mysql/"))))
           (delete 'patch-extension-path)))))
    (inputs
     (modify-inputs (package-inputs guile3-dbi)
       (prepend `(,mariadb "dev")
                `(,mariadb "lib")
                zlib)))
    (native-inputs
     (modify-inputs (package-native-inputs guile3-dbi)
       (prepend guile3-dbi		; only required for headers
                )))
    (synopsis "Guile DBI driver for MySQL")
    (description "@code{guile-dbi} is a library for Guile that provides a
convenient interface to SQL databases.  This package implements the interface
for MySQL.")
    (license license:gpl2+)))

(define-public gn-guile
  (let ((commit "7af301caa7d8a5f01e7e3be007e4ba53dc482eee")
	(revision "0"))
    (package
      (name "gn-guile")
      (version (git-version "4.0.0" revision commit))
      (source (origin
		(method git-fetch)
		(uri (git-reference
		      (url "https://git.genenetwork.org/gn-guile/")
		      (commit commit)))
		(file-name (string-append name "-" version))
		(sha256
		 (base32
                  "0j6nf9k5rdanx5r74dw1rcw7rvyjhzvsv1l5s86jkgkhvrpbb82c"))))
      (build-system guile-build-system)
      (propagated-inputs
       (list guile-3.0 guile3-dbi guile3-dbd-mysql guile-fibers guile-gnutls guile-readline
	     guile-commonmark guile-redis openssl nss-certs gemma parallel guile-hashing
	     guile-json-4))
      (arguments
       (list
	#:phases
	#~(modify-phases %standard-phases
	    ;; When using the guile-build-system, guild doesn't
	    ;; correctly set the GUILE_LOAD_PATH for the various guile
	    ;; packages in the build phase leading to build failures.
	    (add-before 'build 'augment-GUILE_LOAD_PATH
	      (lambda* (#:key outputs #:allow-other-keys)
		(let* ((guile-version (target-guile-effective-version)))
		  ;; guild uses this: "\\.(scm|sls)$" regexp to try and
		  ;; compile all scm files in this repository.  We don't
		  ;; need to compile guix.scm and manifest.scm.
		  (delete-file "guix.scm")
		  (setenv "GUILE_LOAD_PATH"
			  (string-append
			   (format
			    #f "~{~a:~}"
			    (map (lambda (package)
				   (format #f "~a/share/guile/site/~a"
					   package guile-version))
				 (list #$guile3-dbi #$guile-fibers #$guile-commonmark #$guile-json-4 #$guile-hashing)))
			   #$(getenv "GUILE_LOAD_PATH")))))))))
      (home-page "https://git.genenetwork.com/gn-guile")
      (synopsis "Next generation GN code in guile")
      (description "Use of guile.")
      (license license:gpl3))))