gnu: racket: Add aditional mirrors.
[jackhill/guix/guix.git] / gnu / packages / racket.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015, 2016, 2018, 2020 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
4 ;;; Copyright © 2020 Pierre Neidhardt <mail@ambrevar.xyz>
5 ;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
6 ;;;
7 ;;; This file is part of GNU Guix.
8 ;;;
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
13 ;;;
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
18 ;;;
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22 (define-module (gnu packages racket)
23 #:use-module ((guix licenses)
24 #:select (asl2.0 expat lgpl3+))
25 #:use-module (guix packages)
26 #:use-module (guix download)
27 #:use-module (guix git-download)
28 #:use-module (guix utils)
29 #:use-module (guix gexp)
30 #:use-module (guix build-system gnu)
31 #:use-module (srfi srfi-1)
32 #:use-module (ice-9 match)
33 #:use-module (gnu packages)
34 #:use-module (gnu packages bash)
35 #:use-module ((gnu packages chez)
36 #:select (chez-scheme))
37 #:use-module (gnu packages compression)
38 #:use-module (gnu packages databases)
39 #:use-module (gnu packages fontutils)
40 #:use-module (gnu packages gl)
41 #:use-module (gnu packages glib)
42 #:use-module (gnu packages gtk)
43 #:use-module (gnu packages image)
44 #:use-module (gnu packages libedit)
45 #:use-module (gnu packages multiprecision)
46 #:use-module (gnu packages sqlite)
47 #:use-module (gnu packages tls)
48 #:use-module (gnu packages xorg))
49
50
51 (define %installer-mirrors
52 ;; Source:
53 ;; https://github.com/racket/racket-lang-org/blob/master/download/data.rkt#L58
54 ;; Matthew Flatt says: "note that many are commented out"
55 ;; INVARIANT: End with a trailing "/"!
56 '("https://mirror.racket-lang.org/installers/"
57 "https://www.cs.utah.edu/plt/installers/"
58 "https://plt.cs.northwestern.edu/racket-mirror/"
59 "https://mirror.csclub.uwaterloo.ca/racket/racket-installers/"
60 ;; Universität Tübingen is using a self-signed HTTPS certificate:
61 "http://mirror.informatik.uni-tuebingen.de/mirror/racket/"
62 "https://racket.infogroep.be/"
63 ))
64
65
66 (define-public racket-minimal
67 (package
68 (name "racket-minimal")
69 (version "8.0") ; note: remember to also update racket!
70 (source
71 (origin
72 (method url-fetch)
73 (uri (map (lambda (base)
74 (string-append base version "/racket-minimal-src.tgz"))
75 %installer-mirrors))
76 (sha256 "0mwyffw4gcci8wmzxa3j28h03h0gsz55aard8qrk3lri8r2xyg21")
77 (patches (search-patches
78 "racket-sh-via-rktio.patch"))))
79 (home-page "https://racket-lang.org")
80 (synopsis "Racket without bundled packages such as DrRacket")
81 (inputs
82 `(("openssl" ,openssl)
83 ("sqlite" ,sqlite)
84 ("sh" ,bash-minimal)
85 ("zlib" ,zlib)
86 ("zlib:static" ,zlib "static")
87 ("lz4" ,lz4)
88 ("lz4:static" ,lz4 "static")))
89 (build-system gnu-build-system)
90 (arguments
91 `(#:configure-flags
92 `(,(string-append "CPPFLAGS=-DGUIX_RKTIO_PATCH_BIN_SH="
93 (assoc-ref %build-inputs "sh")
94 "/bin/sh")
95 "--enable-libz"
96 "--enable-liblz4")
97 #:modules
98 ((guix build gnu-build-system)
99 (guix build utils)
100 (srfi srfi-1))
101 #:phases
102 (modify-phases %standard-phases
103 (add-after 'unpack 'patch-chez-configure
104 (lambda* (#:key inputs outputs #:allow-other-keys)
105 (substitute* "src/cs/c/Makefile.in"
106 (("/bin/sh") (which "sh")))
107 ;; TODO: Racket CS uses a fork of Chez Scheme.
108 ;; Most of this is copy-pasted from the "chez.scm",
109 ;; but maybe there's a way to reuse more directly.
110 (with-directory-excursion "src/ChezScheme"
111 (substitute* (find-files "mats" "Mf-.*")
112 (("^[[:space:]]+(cc ) *") "\tgcc "))
113 (substitute*
114 (find-files "." (string-append
115 "("
116 "Mf-[a-zA-Z0-9.]+"
117 "|Makefile[a-zA-Z0-9.]*"
118 "|checkin"
119 "|stex\\.stex"
120 "|newrelease"
121 "|workarea"
122 "|unix\\.ms"
123 "|^6\\.ms"
124 ;;"|[a-zA-Z0-9.]+\\.ms" ; guile can't read
125 ")"))
126 (("/bin/rm") (which "rm"))
127 (("/bin/ln") (which "ln"))
128 (("/bin/cp") (which "cp"))
129 (("/bin/echo") (which "echo")))
130 (substitute* "makefiles/installsh"
131 (("/bin/true") (which "true"))))
132 #t))
133 (add-before 'configure 'pre-configure-minimal
134 (lambda* (#:key inputs #:allow-other-keys)
135 (chdir "src")
136 #t))
137 (add-after 'build 'patch-config.rktd-lib-search-dirs
138 (lambda* (#:key inputs outputs #:allow-other-keys)
139 ;; We do this between the `build` and `install` phases
140 ;; so that we have racket to read and write the hash table,
141 ;; but it comes before `raco setup`, when foreign libraries
142 ;; are needed to build the documentation.
143 (define out (assoc-ref outputs "out"))
144 (apply invoke
145 "./cs/c/racketcs"
146 "-e"
147 ,(format #f
148 "~s"
149 '(let* ((args
150 (vector->list
151 (current-command-line-arguments)))
152 (file (car args))
153 (extra-lib-search-dirs (cdr args)))
154 (write-to-file
155 (hash-update
156 (file->value file)
157 'lib-search-dirs
158 (lambda (dirs)
159 (append dirs extra-lib-search-dirs))
160 null)
161 #:exists 'truncate/replace
162 file)))
163 "--"
164 "../etc/config.rktd"
165 (filter-map (lambda (lib)
166 (cond
167 ((assoc-ref inputs lib)
168 => (lambda (pth)
169 (string-append pth "/lib")))
170 (else
171 #f)))
172 '("cairo"
173 "fontconfig"
174 "glib"
175 "glu"
176 "gmp"
177 "gtk+"
178 "libjpeg"
179 "libpng"
180 "libx11"
181 "mesa"
182 "mpfr"
183 "openssl"
184 "pango"
185 "sqlite"
186 "unixodbc"
187 "libedit")))
188 #t)))
189 ;; Tests are in packages like racket-test-core and
190 ;; main-distribution-test that aren't part of the main distribution.
191 #:tests? #f))
192 (description
193 "Racket is a general-purpose programming language in the Scheme family,
194 with a large set of libraries and a compiler based on Chez Scheme. Racket is
195 also a platform for language-oriented programming, from small domain-specific
196 languages to complete language implementations.
197
198 The ``minimal Racket'' distribution includes just enough of Racket for you to
199 use @command{raco pkg} to install more. Bundled packages, such as the
200 DrRacket IDE, are not included.")
201 ;; https://download.racket-lang.org/license.html
202 (license (list lgpl3+ asl2.0 expat))))
203
204
205 (define-public racket
206 (package/inherit
207 racket-minimal
208 (name "racket")
209 (version (package-version racket-minimal)) ; needed for origin uri to work
210 (source
211 (origin
212 (inherit (package-source racket-minimal))
213 (uri (map (lambda (base)
214 (string-append base version "/racket-src.tgz"))
215 %installer-mirrors))
216 (sha256
217 (base32
218 "047wpjblfzmf1msz7snrp2c2h0zxyzlmbsqr9bwsyvz3frcg0888"))))
219 (inputs
220 `(;; sqlite and libraries for `racket/draw' are needed to build the doc.
221 ("cairo" ,cairo)
222 ("fontconfig" ,fontconfig)
223 ("glib" ,glib)
224 ("glu" ,glu)
225 ("gmp" ,gmp)
226 ("gtk+" ,gtk+) ; propagates gdk-pixbuf+svg
227 ("libjpeg" ,libjpeg-turbo)
228 ("libpng" ,libpng)
229 ("libx11" ,libx11)
230 ("mesa" ,mesa)
231 ("mpfr" ,mpfr)
232 ("pango" ,pango)
233 ("unixodbc" ,unixodbc)
234 ("libedit" ,libedit)
235 ,@(package-inputs racket-minimal)))
236 (synopsis "A programmable programming language in the Scheme family")
237 (description
238 "Racket is a general-purpose programming language in the Scheme family,
239 with a large set of libraries and a compiler based on Chez Scheme. Racket is
240 also a platform for language-oriented programming, from small domain-specific
241 languages to complete language implementations.
242
243 The main Racket distribution comes with many bundled packages, including the
244 DrRacket IDE, libraries for GUI and web programming, and implementations of
245 languages such as Typed Racket, R5RS and R6RS Scheme, Algol 60, and Datalog.")))