Merge branch 'version-1.3.0'
[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.1") ; 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 "04zzqybpxss50n1jrwwq98539gw0y0ygpw9civl2sq3s4ww7m8l3")
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-before 'configure 'pre-configure-minimal
104 (lambda* (#:key inputs #:allow-other-keys)
105 (chdir "src")
106 #t))
107 (add-after 'build 'patch-config.rktd-lib-search-dirs
108 (lambda* (#:key inputs outputs #:allow-other-keys)
109 ;; We do this between the `build` and `install` phases
110 ;; so that we have racket to read and write the hash table,
111 ;; but it comes before `raco setup`, when foreign libraries
112 ;; are needed to build the documentation.
113 (define out (assoc-ref outputs "out"))
114 (apply invoke
115 "./cs/c/racketcs"
116 "-e"
117 ,(format #f
118 "~s"
119 '(let* ((args
120 (vector->list
121 (current-command-line-arguments)))
122 (file (car args))
123 (extra-lib-search-dirs (cdr args)))
124 (write-to-file
125 (hash-update
126 (file->value file)
127 'lib-search-dirs
128 (lambda (dirs)
129 (append dirs extra-lib-search-dirs))
130 null)
131 #:exists 'truncate/replace
132 file)))
133 "--"
134 "../etc/config.rktd"
135 (filter-map (lambda (lib)
136 (cond
137 ((assoc-ref inputs lib)
138 => (lambda (pth)
139 (string-append pth "/lib")))
140 (else
141 #f)))
142 '("cairo"
143 "fontconfig"
144 "glib"
145 "glu"
146 "gmp"
147 "gtk+"
148 "libjpeg"
149 "libpng"
150 "libx11"
151 "mesa"
152 "mpfr"
153 "openssl"
154 "pango"
155 "sqlite"
156 "unixodbc"
157 "libedit")))
158 #t)))
159 ;; Tests are in packages like racket-test-core and
160 ;; main-distribution-test that aren't part of the main distribution.
161 #:tests? #f))
162 (description
163 "Racket is a general-purpose programming language in the Scheme family,
164 with a large set of libraries and a compiler based on Chez Scheme. Racket is
165 also a platform for language-oriented programming, from small domain-specific
166 languages to complete language implementations.
167
168 The ``minimal Racket'' distribution includes just enough of Racket for you to
169 use @command{raco pkg} to install more. Bundled packages, such as the
170 DrRacket IDE, are not included.")
171 ;; https://download.racket-lang.org/license.html
172 (license (list lgpl3+ asl2.0 expat))))
173
174
175 (define-public racket
176 (package/inherit
177 racket-minimal
178 (name "racket")
179 (version (package-version racket-minimal)) ; needed for origin uri to work
180 (source
181 (origin
182 (inherit (package-source racket-minimal))
183 (uri (map (lambda (base)
184 (string-append base version "/racket-src.tgz"))
185 %installer-mirrors))
186 (sha256
187 (base32
188 "0xdqwrwm604bbnr97h75dps2ixxz2svlw0fn0f674bn04dcfd60f"))))
189 (inputs
190 `(;; sqlite and libraries for `racket/draw' are needed to build the doc.
191 ("cairo" ,cairo)
192 ("fontconfig" ,fontconfig)
193 ("glib" ,glib)
194 ("glu" ,glu)
195 ("gmp" ,gmp)
196 ("gtk+" ,gtk+) ; propagates gdk-pixbuf+svg
197 ("libjpeg" ,libjpeg-turbo)
198 ("libpng" ,libpng)
199 ("libx11" ,libx11)
200 ("mesa" ,mesa)
201 ("mpfr" ,mpfr)
202 ("pango" ,pango)
203 ("unixodbc" ,unixodbc)
204 ("libedit" ,libedit)
205 ,@(package-inputs racket-minimal)))
206 (synopsis "A programmable programming language in the Scheme family")
207 (description
208 "Racket is a general-purpose programming language in the Scheme family,
209 with a large set of libraries and a compiler based on Chez Scheme. Racket is
210 also a platform for language-oriented programming, from small domain-specific
211 languages to complete language implementations.
212
213 The main Racket distribution comes with many bundled packages, including the
214 DrRacket IDE, libraries for GUI and web programming, and implementations of
215 languages such as Typed Racket, R5RS and R6RS Scheme, Algol 60, and Datalog.")))