;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014 John Darrington ;;; Copyright © 2015 Taylan Ulrich Bayırlı/Kammer ;;; Copyright © 2015 Mark H Weaver ;;; Copyright © 2016 Federico Beffa ;;; Copyright © 2016, 2017 Nikita ;;; Copyright © 2016, 2017 Andy Patterson ;;; Copyright © 2017, 2019 Ricardo Wurmus ;;; Copyright © 2017, 2018, 2019 Efraim Flashner ;;; Copyright © 2017, 2019–2021 Tobias Geerinckx-Rice ;;; Copyright © 2018 Benjamin Slade ;;; Copyright © 2018 Alex Vong ;;; Copyright © 2018, 2019, 2020 Pierre Neidhardt ;;; Copyright © 2018, 2019 Pierre Langlois ;;; Copyright © 2019, 2020 Katherine Cox-Buday ;;; Copyright © 2019 Jesse Gildersleve ;;; Copyright © 2019,
aboutsummaryrefslogtreecommitdiff
blob: 069426a3b8d8b5894cb5c5d05a1e0e280aa0c2fa (about) (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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2019, 2020, 2022 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu installer final)
  #:use-module (gnu installer newt page)
  #:use-module (gnu installer steps)
  #:use-module (gnu installer utils)
  #:use-module (gnu installer user)
  #:use-module (gnu services herd)
  #:use-module (guix build syscalls)
  #:use-module (guix build utils)
  #:use-module (gnu build accounts)
  #:use-module (gnu build install)
  #:use-module (gnu build linux-container)
  #:use-module ((gnu system shadow) #:prefix sys:)
  #:use-module (rnrs io ports)
  #:use-module (srfi srfi-1)
  #:use-module (ice-9 ftw)
  #:use-module (ice-9 popen)
  #:use-module (ice-9 match)
  #:use-module (ice-9 format)
  #:use-module (ice-9 rdelim)
  #:export (install-system))

(define %seed
  (seed->random-state
   (logxor (getpid) (car (gettimeofday)))))

(define (integer->alphanumeric-char n)
  "Map N, an integer in the [0..62] range, to an alphanumeric character."
  (cond ((< n 10)
         (integer->char (+ (char->integer #\0) n)))
        ((< n 36)
         (integer->char (+ (char->integer #\A) (- n 10))))
        ((< n 62)
         (integer->char (+ (char->integer #\a) (- n 36))))
        (else
         (error "integer out of bounds" n))))

(define (random-string len)
  "Compute a random string of size LEN where each character is alphanumeric."
  (let loop ((chars '())
             (len len))
    (if (zero? len)
        (list->string chars)
        (let ((n (random 62 %seed)))
          (loop (cons (integer->alphanumeric-char n) chars)
                (- len 1))))))

(define (create-user-database users root)
  "Create /etc/passwd, /etc/shadow, and /etc/group under ROOT for the given
USERS."
  (define etc
    (string-append root "/etc"))

  (define (salt)
    ;; "$6" gives us a SHA512 password hash; the random string must be taken
    ;; from the './0-9A-Za-z' alphabet (info "(libc) Passphrase Storage").
    (string-append "$6$" (random-string 10)))

  (define users*
    (map (lambda (user)
           (define root?
             (string=? "root" (user-name user)))

           (sys:user-account (name (user-name user))
                             (comment (user-real-name user))
                             (group "users")
                             (uid (if root? 0 #f))
                             (home-directory
                              (user-home-directory user))
                             (password (crypt
                                        (secret-content (user-password user))
                                        (salt)))

                             ;; We need a string here, not a file-like, hence
                             ;; this choice.
                             (shell
                              "/run/current-system/profile/bin/bash")))
         users))

  (define-values (group password shadow)
    (user+group-databases users* sys:%base-groups
                          #:current-passwd '()
                          #:current-groups '()
                          #:current-shadow '()))

  (mkdir-p etc)
  (write-group group (string-append etc "/group"))
  (write-passwd password (string-append etc "/passwd"))
  (write-shadow shadow (string-append etc "/shadow")))

(define (call-with-mnt-container thunk)
  "This is a variant of call-with-container. Run THUNK in a new container
process, within a separate MNT namespace. The container is not jailed so that
it can interact with the rest of the system."
  (let ((pid (run-container "/" '() '(mnt) 1 thunk)))
    ;; Catch SIGINT and kill the container process.
    (sigaction SIGINT
      (lambda (signum)
        ;: FIXME: Use of SIGKILL prevents the dynamic-wind exit handler of
        ;; THUNK to run.
        (false-if-exception
         (kill pid SIGKILL))))

    (match (waitpid pid)
      ((_ . status) status))))

(define (install-locale locale)
  "Install the given LOCALE or the en_US.utf8 locale as a fallback."
  (let ((supported? (false-if-exception
                     (setlocale LC_ALL locale))))
    (if supported?
        (begin
          (installer-log-line "install supported locale ~a." locale)
          (setenv "LC_ALL" locale))
        (begin
          ;; If the selected locale is not supported, install a default UTF-8
          ;; locale. This is required to copy some files with UTF-8
          ;; characters, in the nss-certs package notably. Set LANGUAGE
          ;; anyways, to have translated messages if possible.
          (installer-log-line "~a locale is not supported, installing \
en_US.utf8 locale instead." locale)
          (setlocale LC_ALL "en_US.utf8")
          (setenv "LC_ALL" "en_US.utf8")
          (setenv "LANGUAGE"
                  (string-take locale
                               (or (string-index locale #\_)
                                   (string-length locale))))))))

(define* (install-system locale #:key (users '()))
  "Create /etc/shadow and /etc/passwd on the installation target for USERS.
Start COW-STORE service on target directory and launch guix install command in
a subshell.  LOCALE must be the locale name under which that command will run,
or #f.  Return #t on success and #f on failure."
  (define backing-directory
    ;; Sub-directory used as the backing store for copy-on-write.
    "/tmp/guix-inst")

  (define (assert-exit x)
    (primitive-exit (if x 0 1)))

  (let* ((options         (catch 'system-error
                            (lambda ()
                              ;; If this file exists, it can provide
                              ;; additional command-line options.
                              (call-with-input-file
                                  "/tmp/installer-system-init-options"
                                read))
                            (const '())))
         (install-command (append (list "guix" "system" "init"
                                        "--fallback")
                                  options
                                  (list (%installer-configuration-file)
                                        (%installer-target-dir))))
         (database-dir    "/var/guix/db")
         (database-file   (string-append database-dir "/db.sqlite"))
         (saved-database  (string-append database-dir "/db.save"))
         (ret             #f))
    (mkdir-p (%installer-target-dir))

    ;; We want to initialize user passwords but we don't want to store them in
    ;; the config file since the password hashes would end up world-readable
    ;; in the store.  Thus, create /etc/shadow & co. here such that, on the
    ;; first boot, the activation snippet that creates accounts will reuse the
    ;; passwords that we've put in there.
    (create-user-database users (%installer-target-dir))

    ;; When the store overlay is mounted, other processes such as kmscon, udev
    ;; and guix-daemon may open files from the store, preventing the
    ;; underlying install support from being umounted. See:
    ;; https://lists.gnu.org/archive/html/guix-devel/2018-12/msg00161.html.
    ;;
    ;; To avoid this situation, mount the store overlay inside a container,
    ;; and run the installation from within that container.
    (zero?
     (call-with-mnt-container
       (lambda ()
         (dynamic-wind
           (lambda ()
             ;; Install the locale before mounting the cow-store, otherwise
             ;; the loaded cow-store locale files will prevent umounting.
             (install-locale locale)

             ;; Stop the daemon and save the database, so that it can be
             ;; restored once the cow-store is umounted.
             (stop-service 'guix-daemon)
             (copy-file database-file saved-database)

             (installer-log-line "mounting copy-on-write store")
             (mount-cow-store (%installer-target-dir) backing-directory))
           (lambda ()
             ;; We need to drag the guix-daemon to the container MNT
             ;; namespace, so that it can operate on the cow-store.
             (start-service 'guix-daemon (list (number->string (getpid))))

             (setvbuf (current-output-port) 'none)
             (setvbuf (current-error-port) 'none)

             (setenv "PATH" "/run/current-system/profile/bin/")

             (set! ret (run-command install-command #:tty? #t)))
           (lambda ()
             ;; Stop guix-daemon so that it does no keep the MNT namespace
             ;; alive.
             (stop-service 'guix-daemon)

             ;; Restore the database and restart it.  As part of restoring the
             ;; database, remove the WAL and shm files in case they were left
             ;; behind after guix-daemon was stopped.  Failing to do so,
             ;; sqlite might behave as if transactions that appear in the WAL
             ;; file were committed.  (See <https://www.sqlite.org/wal.html>.)
             (installer-log-line "restoring store database from '~a'"
                                 saved-database)
             (copy-file saved-database database-file)
             (for-each (lambda (suffix)
                         (false-if-exception
                          (delete-file (string-append database-file suffix))))
                       '("-wal" "-shm"))
             (start-service 'guix-daemon)

             ;; Finally umount the cow-store and exit the container.
             (installer-log-line "unmounting copy-on-write store")
             (unmount-cow-store (%installer-target-dir) backing-directory)
             (assert-exit ret))))))))
h files too (which contain Lisp code). Use ;; ISO-8859-1 because some of the files are ISO-8859-1 encoded. (with-fluids ((%default-port-encoding #f)) ;; The removed file is utf-16-be encoded, which gives substitute* ;; trouble. It does not contain references to the listed programs. (substitute* (delete "./tests/data/compile-file-pos-utf16be.lisp" (find-files "." "\\.(lisp|sh)$")) (("\"/bin/sh\"") (quoted-path bash "/bin/sh")) (("\"/usr/bin/env\"") (quoted-path coreutils "/usr/bin/env")) (("\"/bin/cat\"") (quoted-path coreutils "/bin/cat")) (("\"/bin/ed\"") (quoted-path ed "/bin/ed")) (("\"/bin/echo\"") (quoted-path coreutils "/bin/echo")) (("\"/bin/uname\"") (quoted-path coreutils "/bin/uname")))) ;; This one script has a non-string occurrence of /bin/sh. (substitute* '("tests/foreign.test.sh") ;; Leave whitespace so we don't match the shebang. ((" /bin/sh ") " sh ")) ;; This file contains a module that can create executable files ;; which depend on the presence of SBCL. It generates shell ;; scripts doing "exec sbcl ..." to achieve this. We patch both ;; the shebang and the reference to "sbcl", tying the generated ;; executables to the exact SBCL package that generated them. (substitute* '("contrib/sb-executable/sb-executable.lisp") (("/bin/sh") (string-append bash "/bin/sh")) (("exec sbcl") (string-append "exec " out "/bin/sbcl"))) ;; Disable some tests that fail in our build environment. (substitute* '("contrib/sb-bsd-sockets/tests.lisp") ;; This requires /etc/protocols. (("\\(deftest get-protocol-by-name/error" all) (string-append "#+nil ;disabled by Guix\n" all))) (substitute* '("contrib/sb-posix/posix-tests.lisp") ;; These assume some users/groups which we don't have. (("\\(deftest pwent\\.[12]" all) (string-append "#+nil ;disabled by Guix\n" all)) (("\\(deftest grent\\.[12]" all) (string-append "#+nil ;disabled by Guix\n" all)))) #t)) ;; FIXME: the texlive-union insists on regenerating fonts. It stores ;; them in HOME, so it needs to be writeable. (add-before 'build 'set-HOME (lambda _ (setenv "HOME" "/tmp") #t)) (replace 'build (lambda* (#:key outputs #:allow-other-keys) (setenv "CC" "gcc") (invoke "sh" "make.sh" ,@(match (%current-system) ((or "x86_64-linux" "i686-linux") `("clisp")) (_ `("clisp"))) (string-append "--prefix=" (assoc-ref outputs "out")) "--dynamic-space-size=3072" "--with-sb-core-compression" "--with-sb-xref-for-internals"))) (replace 'install (lambda _ (invoke "sh" "install.sh"))) (add-after 'build 'build-doc (lambda _ ;; TODO: Doc is not deterministic, maybe there is a timespamp? (with-directory-excursion "doc/manual" (and (invoke "make" "info") (invoke "make" "dist"))))) (add-after 'build 'build-source (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (rc (string-append out "/lib/sbcl/sbclrc")) (source-dir (string-append out "/share/sbcl"))) (for-each (lambda (p) (copy-recursively p (string-append source-dir "/" p))) '("src" "contrib")) (mkdir-p (dirname rc)) (with-output-to-file rc (lambda () (display (string-append "(sb-ext:set-sbcl-source-location \"" source-dir "\")") ))) #t))) (add-after 'install 'install-doc (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (doc (assoc-ref outputs "doc")) (old-doc-dir (string-append out "/share/doc")) (new-doc/sbcl-dir (string-append doc "/share/doc/sbcl"))) (rmdir (string-append old-doc-dir "/sbcl/html")) (mkdir-p new-doc/sbcl-dir) (copy-recursively (string-append old-doc-dir "/sbcl") new-doc/sbcl-dir) (delete-file-recursively old-doc-dir) #t)))) ;; No 'check' target, though "make.sh" (build phase) runs tests. #:tests? #f)) (native-search-paths (list (search-path-specification (variable "XDG_DATA_DIRS") (files '("share"))) (search-path-specification (variable "XDG_CONFIG_DIRS") (files '("etc"))))) (home-page "http://www.sbcl.org/") (synopsis "Common Lisp implementation") (description "Steel Bank Common Lisp (SBCL) is a high performance Common Lisp compiler. In addition to the compiler and runtime system for ANSI Common Lisp, it provides an interactive environment including a debugger, a statistical profiler, a code coverage tool, and many other extensions.") ;; Public domain in jurisdictions that allow it, bsd-2 otherwise. MIT ;; loop macro has its own license. See COPYING file for further notes. (license (list license:public-domain license:bsd-2 (license:x11-style "file://src/code/loop.lisp"))))) (define-public ccl ;; Warning: according to upstream, CCL is not bootstrappable. ;; See https://github.com/Clozure/ccl/issues/222 from 2019-09-02: ;; ;; "As far as I know, there is no way to build CCL without an existing ;; running CCL image. It was bootstrapped back in 1986 or so as ;; Macintosh Common Lisp, by Gary Byers, I believe, who is no longer on ;; the planet to tell us the story. It SHOULD be possible to port the ;; CCL compiler to portable Common Lisp, so that ANY lisp could build ;; it, as is the case for SBCL, but I know of no attempt to do so." (package (name "ccl") ;; XXX When updating this package, check whether we can simply append ;; VERSION to the ccl-bootstrap URL again, instead of per architecture. (version "1.12.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/Clozure/ccl/") (commit (string-append "v" version)))) (file-name (git-file-name "ccl" version)) (sha256 (base32 "1zz291lvsrr7pps8wfl2kdxsnzjngqi4v3mil14pga4r5zanmsi7")))) (build-system gnu-build-system) ;; CCL consists of a "lisp kernel" and "heap image", both of which are ;; shipped in precompiled form in source tarballs. The former is a C ;; program which we can rebuild from scratch, but the latter cannot be ;; generated without an already working copy of CCL, and is platform ;; dependent, so we need to fetch the correct tarball for the platform. (inputs `(("ccl-bootstrap" ,(origin (method url-fetch) (uri (string-append "https://github.com/Clozure/ccl/releases/download/v" (match (%current-system) ("armhf-linux" "1.12/linuxarm") ;; XXX: This source only works on x86, but provide it as a ;; catch-all to prevent errors when querying this package ;; on unsupported platforms. (_ "1.12.1/linuxx86")) ".tar.gz")) (sha256 (base32 (match (%current-system) ("armhf-linux" "0x4bjx6cxsjvxyagijhlvmc7jkyxifdvz5q5zvz37028va65243c") (_ "0ll017ajcfsyx8f7zsy4394y8xxvz40iz0gcsmznp0n3mf0xi67c")))))))) (native-inputs `(("cl-asdf" ,cl-asdf) ("m4" ,m4))) (arguments `(#:tests? #f ;no 'check' target #:modules ((ice-9 match) (srfi srfi-26) (guix build utils) (guix build gnu-build-system)) #:phases (modify-phases %standard-phases (add-after 'unpack 'unpack-image (lambda* (#:key inputs #:allow-other-keys) (invoke "tar" "xzvf" (assoc-ref inputs "ccl-bootstrap")))) (add-after 'unpack 'replace-asdf ;; Use system ASDF instead of bundled one. (lambda* (#:key inputs #:allow-other-keys) (let* ((cl-asdf (assoc-ref inputs "cl-asdf")) (guix-asdf (string-append cl-asdf "/share/common-lisp/source/asdf/asdf.lisp")) (contrib-asdf "tools/asdf.lisp")) (delete-file contrib-asdf) (copy-file guix-asdf contrib-asdf)))) (delete 'configure) (add-before 'build 'pre-build ;; Enter the source directory for the current platform's lisp ;; kernel, and run 'make clean' to remove the precompiled one. (lambda* (#:key system #:allow-other-keys) (substitute* "lisp-kernel/m4macros.m4" (("/bin/pwd") (which "pwd"))) (chdir (string-append "lisp-kernel/" (match system ("i686-linux" "linuxx8632") ("x86_64-linux" "linuxx8664") ("armhf-linux" "linuxarm") (_ (string-append "unknown system: " system))))) (substitute* '("Makefile") (("/bin/rm") "rm")) (setenv "CC" "gcc") (invoke "make" "clean"))) ;; XXX Do we need to recompile the heap image as well for Guix? ;; For now just use the one we already got in the tarball. (replace 'install (lambda* (#:key outputs inputs system #:allow-other-keys) ;; The lisp kernel built by running 'make' in lisp-kernel/$system ;; is put back into the original directory, so go back. The heap ;; image is there as well. (chdir "../..") (let* ((out (assoc-ref outputs "out")) (libdir (string-append out "/lib/")) (bindir (string-append out "/bin/")) (wrapper (string-append bindir "ccl")) (bash (assoc-ref inputs "bash")) (kernel (match system ("i686-linux" "lx86cl") ("x86_64-linux" "lx86cl64") ("armhf-linux" "armcl") ;; Unlikely to work, but try it anyway... (_ system))) (heap (string-append kernel ".image"))) (install-file kernel libdir) (install-file heap libdir) (let ((dirs `("lib" "library" "examples" "tools" "objc-bridge" ,@(match system ("x86_64-linux" '("x86-headers64")) ("i686-linux" '("x86-headers")) (_ '()))))) (for-each copy-recursively dirs (map (cut string-append libdir <>) dirs))) (mkdir-p bindir) (with-output-to-file wrapper (lambda () (display (string-append "#!" bash "/bin/sh\n" "export CCL_DEFAULT_DIRECTORY=" libdir "\n" "exec -a \"$0\" " libdir kernel " \"$@\"\n")))) (chmod wrapper #o755)) #t))))) (native-search-paths (list (search-path-specification (variable "XDG_DATA_DIRS") (files '("share"))) (search-path-specification (variable "XDG_CONFIG_DIRS") (files '("etc"))))) (supported-systems '("i686-linux" "x86_64-linux" "armhf-linux")) (home-page "https://ccl.clozure.com/") (synopsis "Common Lisp implementation") (description "Clozure CL (often called CCL for short) is a Common Lisp implementation featuring fast compilation speed, native threads, a precise, generational, compacting garbage collector, and a convenient foreign-function interface.") (license license:asl2.0))) (define-public lush2 (package (name "lush2") (version "2.0.1") (source (origin (method url-fetch) (uri (string-append "mirror://sourceforge/lush/lush2/lush-" version ".tar.gz")) (modules '((guix build utils))) (snippet '(begin (substitute* "src/unix.c" (("\\{ \"LUSH_DATE\", __DATE__ \\},") "") (("\\{ \"LUSH_TIME\", __TIME__ \\},") "")) (substitute* "src/main.c" (("\" \\(built \" __DATE__ \"\\)\"") "")) #t)) (sha256 (base32 "02pkfn3nqdkm9fm44911dbcz0v3r0l53vygj8xigl6id5g3iwi4k")))) (build-system gnu-build-system) (arguments `(;; We have to add these LIBS so that they are found. #:configure-flags (list "LIBS=-lz" "X_EXTRA_LIBS=-lfontconfig" "--with-x") #:tests? #f)) ; No make check. (native-inputs `(("intltool" ,intltool))) (inputs `(("alsa-lib" ,alsa-lib) ("sdl" ,sdl) ("sdl-image" ,sdl-image) ("sdl-mixer" ,sdl-mixer) ("sdl-net" ,sdl-net) ("sdl-ttf" ,sdl-ttf) ("lapack" ,lapack) ("libxft" ,libxft) ("fontconfig" ,fontconfig) ("gsl" ,gsl) ("openblas" ,openblas) ("glu" ,glu) ("mesa" ,mesa) ("mesa-utils" ,mesa-utils) ("binutils" ,binutils) ("libiberty" ,libiberty) ("readline" ,readline) ("zlib" ,zlib) ("gettext-minimal" ,gettext-minimal))) (synopsis "Lisp Universal Shell") (description "Lush is an object-oriented Lisp interpreter/compiler with features designed to please people who want to prototype large numerical applications. Lush includes an extensive library of vector/matrix/tensor manipulation, numerous numerical libraries (including GSL, LAPACK, and BLAS), a set of graphic functions, a simple GUI toolkit, and interfaces to various graphic and multimedia libraries such as OpenGL, SDL, Video4Linux, and ALSA (video/audio grabbing), and others. Lush is an ideal frontend script language for programming projects written in C or other languages. Lush also has libraries for Machine Learning, Neural Nets and statistical estimation.") (home-page "http://lush.sourceforge.net/") (license license:lgpl2.1+))) (define-public confusion-mdl (let* ((commit "12a055581fc262225272df43287dae48281900f5")) (package (name "confusion-mdl") (version "0.2") (source (origin (method git-fetch) (uri (git-reference (url (string-append "https://gitlab.com/emacsomancer/" name)) (commit commit))) (sha256 (base32 "1zi8kflzvwqg97ha1sa5xjisbjs5z1mvbpa772vfxiv5ksnpxp0d")) (file-name (git-file-name name version)))) (build-system gnu-build-system) (arguments `(#:tests? #f ; there are no tests #:phases (modify-phases %standard-phases (delete 'configure) (replace 'build (lambda* (#:key (make-flags '()) #:allow-other-keys) (apply invoke "make" "CC=gcc" make-flags))) (replace 'install (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (bin (string-append out "/bin"))) (install-file "mdli" bin) #t)))))) (native-inputs `(("perl" ,perl))) (inputs `(("libgc" ,libgc))) (synopsis "Interpreter for the MIT Design Language (MDL)") (description "MDL (the MIT Design Language) is a descendant of Lisp. It was originally developed in 1971 on the PDP-10 computer under the Incompatible Timesharing System (ITS) to provide high level language support for the Dynamic Modeling Group at MIT's Project MAC. Infocom built the original PDP-10 Zork in MDL and their later ZIL (Zork Implementation Language) was based on a subset of MDL. Confusion is a MDL interpreter that works just well enough to play the original mainframe Zork all the way through.") (home-page "http://www.russotto.net/git/mrussotto/confusion/src/master/src/README") (license license:gpl3+)))) (define man-for-txr (let ((commit "dfbf19b9a96474b8c1bacac85e43605e5691ceb2") ;; Number of additional commits since the last tag (see the output of ;; "git describe --tags"). (revision "41")) (package (name "man-for-txr") (version (git-version "1.6g" revision commit)) (source (origin (method git-fetch) (uri (git-reference (url "http://www.kylheku.com/git/man/") (commit commit))) (file-name (git-file-name name version)) (sha256 (base32 "1zy0g8fj9nsfwzvg88hyaiy94r8j14xhs8vy2ln2niqdm6x2lvy2")))) (build-system gnu-build-system) (arguments `(#:tests? #f ; There are no tests. #:phases (modify-phases %standard-phases (add-after 'unpack 'fix-man2html-makefile (lambda _ (substitute* "man2html/Makefile.in" ;; It inadvertently ignores @bindir@. (("^(bindir = \\$\\(DESTDIR\\)\\$\\(PREFIX\\)).*" _ prefix) (string-append prefix "@bindir@\n"))) #t)) (add-after 'unpack 'delete-generated-files (lambda _ (for-each delete-file (append (list "conf_script") (map (lambda (d) (string-append d "/Makefile")) '("." "man" "man2html" "src")) (map (lambda (f) (string-append "src/" f)) '("makewhatis.in" "man.conf" "paths.h" "version.h")))) #t)) (replace 'configure (lambda* (#:key outputs #:allow-other-keys) (setenv "CC" ,(cc-for-target)) ;; Humor the manually written configure script. (invoke "./configure" "+lang" "en" "+fhs" (string-append "-prefix=" (assoc-ref outputs "out"))) #t))))) (home-page "http://www.kylheku.com/cgit/man/") (synopsis "Modifications to the man utilities, specifically man2html") (description "This is a fork of the man utilities intended specifically for building the HTML documentation of TXR.") (license license:gpl2)))) (define-public txr (package (name "txr") (version "270") (source (origin (method git-fetch) (uri (git-reference (url "http://www.kylheku.com/git/txr/") (commit (string-append "txr-" version)))) (file-name (git-file-name name version)) (sha256 (base32 "1kp64h3ls8mddvrlaqqylrb3brckfrqvkk8049xn15mimfggg0xv")))) (build-system gnu-build-system) (native-inputs ;; Required to build the documentation. `(("ghostscript" ,ghostscript) ("groff" ,groff) ("man2html" ,man-for-txr))) (inputs `(("bash" ,bash-minimal) ("libffi" ,libffi))) (arguments `(#:configure-flags (list ,(string-append "cc=" (cc-for-target)) (string-append "--prefix=" (assoc-ref %outputs "out"))) #:test-target "tests" #:phases (modify-phases %standard-phases (add-after 'unpack 'fix-license-installation (lambda* (#:key outputs #:allow-other-keys) (substitute* "Makefile" (("INSTALL(,.*LICENSE,.*)\\$\\(datadir\\)" _ match) (string-append "INSTALL" match (assoc-ref outputs "out") "/share/doc/" ,name "-" ,version))) #t)) (delete 'install-license-files) (add-after 'unpack 'inhibit-doc-syms-generation (lambda _ (substitute* "genman.txr" ;; Exit from genman.txr before it tries to write to ;; stdlib/doc-syms.tl, which is anyway kept up to date with ;; each release (and is already compiled to stdlib/doc-syms.tlo ;; when genman.txr is run). (("^@\\(output \"stdlib/doc-syms\\.tl\"\\).*" line) (string-append "@(do (exit))\n" line))) #t)) (add-after 'unpack 'fix-paths (lambda* (#:key inputs #:allow-other-keys) (substitute* "stream.c" (("/bin/sh") (string-append (assoc-ref inputs "bash") "/bin/bash"))))) (add-after 'unpack 'fix-tests (lambda _ (substitute* (list "tests/017/realpath.tl" "tests/017/realpath.expected") (("/usr/bin") "/")))) (replace 'configure ;; ./configure is a hand-written script that can't handle standard ;; autotools arguments like CONFIG_SHELL. (lambda* (#:key configure-flags #:allow-other-keys) (setenv "txr_shell" (which "bash")) (apply invoke "./configure" configure-flags) #t)) (add-after 'build 'build-doc (lambda _ (setenv "GS_GENERATE_UUIDS" "0") (invoke "make" "txr-manpage.html" "txr-manpage.pdf") #t)) (add-after 'install 'install-doc (lambda* (#:key outputs #:allow-other-keys) (let ((doc (string-append (assoc-ref outputs "out") "/share/doc/" ,name "-" ,version))) (for-each (lambda (f) (install-file f doc)) '("txr-manpage.html" "txr-manpage.pdf"))) #t))))) (synopsis "General-purpose, multi-paradigm programming language") (description "TXR is a general-purpose, multi-paradigm programming language. It comprises two languages integrated into a single tool: a text scanning and extraction language referred to as the TXR Pattern Language (sometimes just \"TXR\"), and a general-purpose dialect of Lisp called TXR Lisp. TXR can be used for everything from \"one liner\" data transformation tasks at the command line, to data scanning and extracting scripts, to full application development in a wide-range of areas.") (home-page "https://nongnu.org/txr/") (license license:bsd-2))) (define picolisp32 (package (name "picolisp32") (version "19.12") (source (origin (method url-fetch) (uri (string-append "https://software-lab.de/picoLisp-" version ".tgz")) (sha256 (base32 "10np0mhihr47r3201617zccrvzpkhdl1jwvz7zimk8kxpriydq2j")) (modules '((guix build utils))) (snippet '(begin ;; Delete the pre-compiled jar file. (delete-file "ersatz/picolisp.jar") #t)))) (build-system gnu-build-system) (inputs `(("openssl" ,openssl))) (arguments `(#:system ,(match (%current-system) ((or "armhf-linux" "aarch64-linux") "armhf-linux") (_ "i686-linux")) #:phases (modify-phases %standard-phases (delete 'configure) (add-after 'unpack 'fix-paths (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (shebang-line (string-append "#!" out "/bin/picolisp " out "/lib/picolisp/lib.l"))) (substitute* '("bin/pil" "bin/pilIndent" "bin/pilPretty" "bin/psh" "bin/replica" "bin/vip" "bin/watchdog" "games/xchess" "misc/bigtest" "misc/calc" "misc/chat" "misc/mailing" "src/mkVers") (("#\\!bin/picolisp lib.l") shebang-line) (("#\\!\\.\\./bin/picolisp \\.\\./lib.l") shebang-line) (("#\\!/usr/bin/picolisp /usr/lib/picolisp/lib.l") shebang-line))) #t)) (add-after 'fix-paths 'make-build-reproducible (lambda _ (substitute* "src64/lib/asm.l" (("\\(prinl \"/\\* \" \\(datSym \\(date\\)\\) \" \\*/\\)") "")) #t)) (add-after 'make-build-reproducible 'fix-permissions (lambda _ (for-each make-file-writable '("doc/family.tgz" "doc/family64.tgz" "lib/map" "src64/tags")) #t)) (replace 'build (lambda _ (invoke "make" "-C" "src" "picolisp" "tools" "gate"))) (add-before 'check 'set-home-for-tests (lambda _ (setenv "HOME" "/tmp") #t)) (replace 'check (lambda _ (invoke "./pil" "test/lib.l" "-bye" "+"))) (replace 'install (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (bin (string-append out "/bin")) (man (string-append out "/share/man")) (picolisp (string-append out "/lib/picolisp"))) (copy-recursively "man" man) (copy-recursively "." picolisp) (for-each (lambda (name) (let ((path (string-append picolisp "/" name))) (delete-file-recursively path))) '("CHANGES" "COPYING" "CREDITS" "cygwin" "INSTALL" "man" "pil" "README" "src" "src64" "test")) (mkdir-p bin) (symlink (string-append picolisp "/bin/picolisp") (string-append bin "/picolisp")) (symlink (string-append picolisp "/bin/pil") (string-append bin "/pil"))) #t))))) (synopsis "Interpreter for the PicoLisp programming language") (description "PicoLisp is a programming language, or really a programming system, including a built-in database engine and a GUI system.") (home-page "https://picolisp.com/wiki/?home") (license license:expat))) (define-public picolisp (match (%current-system) ((or "aarch64-linux" "x86_64-linux") (package ;; Use the 32-bit picolisp to generate the assembly files required by ;; the 64-bit picolisp. (inherit picolisp32) (name "picolisp") (native-inputs `(("picolisp32" ,picolisp32) ("which" ,which))) (arguments (substitute-keyword-arguments (package-arguments picolisp32) ((#:system _ "") (%current-system)) ((#:phases phases) `(modify-phases ,phases (delete 'fix-paths) (add-before 'build 'fix-paths ;; This must run after the other shebang-patching phases, ;; or they will override our changes. (lambda* (#:key inputs outputs #:allow-other-keys) (let* ((picolisp32 (assoc-ref inputs "picolisp32")) (out (assoc-ref outputs "out")) (shebang-line (string-append "#!" out "/bin/picolisp " out "/lib/picolisp/lib.l"))) (substitute* '("bin/pil" "bin/pilIndent" "bin/pilPretty" "bin/psh" "bin/replica" "bin/vip" "bin/watchdog" "games/xchess" "misc/bigtest" "misc/calc" "misc/chat" "misc/mailing" "src/mkVers") (("#\\!.*picolisp32.*/bin/picolisp .*lib\\.l") shebang-line)) (substitute* "src64/mkAsm" (("/usr/bin/") (string-append picolisp32 "/bin/")))) #t)) (replace 'build (lambda _ (invoke "make" "-C" "src" "tools" "gate") (invoke "make" "-C" "src64" "CC=gcc" "picolisp"))))))))) (_ (package (inherit picolisp32) (name "picolisp"))))) (define-public janet (package (name "janet") (version "1.18.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/janet-lang/janet") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "07k92ip4vmqpzbz32spkpy2rz7pxfsdyl77sy9fylqmc6vg32hr8")))) (build-system gnu-build-system) (arguments `(#:make-flags (list (string-append "DESTDIR=" (assoc-ref %outputs "out")) (string-append "PREFIX=") (string-append "CC=" ,(cc-for-target))) #:test-target "test" #:phases (modify-phases %standard-phases (delete 'configure)))) (home-page "https://janet-lang.org/") (synopsis "Functional, imperative and embeddable programming language") (description "Janet is a functional and imperative programming language. It can be used for rapid prototyping, dynamic systems, and other domains where dynamic languages shine. You can also add Janet scripting to an application by embedding a single C file and two headers. It can be easily ported to new platforms. The entire language (core library, interpreter, compiler, assembler, PEG) is less than 1MB.") (license license:expat))) (define-public lisp-repl-core-dumper (package (name "lisp-repl-core-dumper") (version "0.7.0") (source (origin (method git-fetch) (uri (git-reference (url "https://gitlab.com/ambrevar/lisp-repl-core-dumper.git") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "0yfsyxj462yi3bx587yssp4gwb54jdm6fjk9q93gjrfv8a65ilp7")))) (build-system copy-build-system) (arguments '(#:install-plan '(("lisp-repl-core-dumper" "bin/")) #:phases (modify-phases %standard-phases (add-before 'install 'fix-utils-path (lambda* (#:key inputs #:allow-other-keys) (let* ((coreutils (string-append (assoc-ref inputs "coreutils") "/bin/")) (cat (string-append coreutils "cat")) (paste (string-append coreutils "paste")) (sort (string-append coreutils "sort")) (basename (string-append coreutils "basename")) (sed (string-append (assoc-ref inputs "sed") "/bin/sed"))) (substitute* "lisp-repl-core-dumper" (("\\$\\(basename") (string-append "$(" basename)) (("\\") cat) (("\\") paste) (("\\") sed) (("\\") sort)))))))) (inputs `(("coreutils" ,coreutils-minimal) ("sed" ,sed))) (home-page "https://gitlab.com/ambrevar/lisp-repl-core-dumper") (synopsis "Generate REPL-optimized Lisp cores on demand") (description "This tool generates Lisp images that can embed the provided systems and make for REPLs that start blazing fast. @itemize @item It’s portable and should work with any compiler. @item It works for any REPL. @item It allows you to include arbitrary libraries. @end itemize\n") (license license:gpl3+))) (define-public buildapp (package (name "buildapp") (version "1.5.6") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/xach/buildapp") (commit (string-append "release-" version)))) (file-name (git-file-name name version)) (sha256 (base32 "020ipjfqa3l8skd97cj5kq837wgpj28ygfxnkv64cnjrlbnzh161")))) (build-system gnu-build-system) (native-inputs `(("sbcl" ,sbcl))) (arguments `(#:tests? #f #:make-flags (list (string-append "DESTDIR=" (assoc-ref %outputs "out"))) #:strip-binaries? #f #:phases (modify-phases %standard-phases (delete 'configure) (add-after 'unpack 'set-home (lambda _ (setenv "HOME" "/tmp") #t)) (add-before 'install 'create-target-directory (lambda* (#:key outputs #:allow-other-keys) (let* ((bin (string-append (assoc-ref outputs "out") "/bin"))) (mkdir-p bin) #t)))))) (home-page "https://www.xach.com/lisp/buildapp/") (synopsis "Makes easy to build application executables with SBCL") (description "Buildapp is an application for SBCL or CCL that configures and saves an executable Common Lisp image. It is similar to cl-launch and hu.dwim.build. ") (license license:bsd-2)))