gnu: hurd: Add dependency on libgcrypt.
[jackhill/guix/guix.git] / gnu / packages / hurd.scm
CommitLineData
0193c004 1;;; GNU Guix --- Functional package management for GNU
8df672aa 2;;; Copyright © 2014, 2015, 2016, 2017 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
e62f6f77 3;;; Copyright © 2018, 2020 Ludovic Courtès <ludo@gnu.org>
fb9d6f0f 4;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
f379c665 5;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
9b943db3 6;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
0193c004
MR
7;;;
8;;; This file is part of GNU Guix.
9;;;
10;;; GNU Guix is free software; you can redistribute it and/or modify it
11;;; under the terms of the GNU General Public License as published by
12;;; the Free Software Foundation; either version 3 of the License, or (at
13;;; your option) any later version.
14;;;
15;;; GNU Guix is distributed in the hope that it will be useful, but
16;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;;; GNU General Public License for more details.
19;;;
20;;; You should have received a copy of the GNU General Public License
21;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22
23(define-module (gnu packages hurd)
24 #:use-module (guix licenses)
25 #:use-module (guix download)
26 #:use-module (guix packages)
21a8fe1b 27 #:use-module (gnu packages)
f46cf8ef 28 #:use-module (guix gexp)
e1ecd50e 29 #:use-module (guix utils)
396b3c8b 30 #:use-module (guix build-system gnu)
38efbcbb 31 #:use-module (guix build-system trivial)
2d546858 32 #:use-module (gnu packages autotools)
396b3c8b 33 #:use-module (gnu packages flex)
abbeaf54 34 #:use-module (gnu packages gnupg)
dc91c10f 35 #:use-module (gnu packages bison)
29505c7d 36 #:use-module (gnu packages linux)
dc91c10f 37 #:use-module (gnu packages perl)
21a8fe1b 38 #:use-module (gnu packages base)
29505c7d 39 #:use-module (gnu packages bash)
fb9d6f0f 40 #:use-module (gnu packages texinfo)
62596a15 41 #:use-module (guix git-download)
9b943db3
JN
42 #:export (hurd-system?
43 hurd-target?
44 hurd-triplet?))
62596a15
MR
45
46(define (hurd-triplet? triplet)
47 (and (string-suffix? "-gnu" triplet)
48 (not (string-contains triplet "linux"))))
0193c004 49
2d546858
LC
50(define (hurd-target?)
51 "Return true if the cross-compilation target or the current system is
52GNU/Hurd."
53 (or (and=> (%current-target-system) hurd-triplet?)
9b943db3
JN
54 (and (not (%current-target-system))
55 (and=> (%current-system) hurd-triplet?))))
56
57(define (hurd-system?)
58 "Return true if the current system is the Hurd."
59 (and=> (%current-system) hurd-triplet?))
2d546858 60
b005a37a
MR
61(define (hurd-source-url version)
62 (string-append "mirror://gnu/hurd/hurd-"
63 version ".tar.gz"))
64
0193c004 65(define-public gnumach-headers
fb9d6f0f
EF
66 (let ((commit "097f9cf735ffa1212b828682ad92f0f6c5f1c552")
67 (revision "1"))
68 (package
69 (name "gnumach-headers")
70 (version (git-version "1.8" revision commit))
71 (source
72 (origin
73 (method git-fetch)
74 (uri (git-reference
75 (url "https://git.savannah.gnu.org/git/hurd/gnumach.git")
76 (commit commit)))
77 (file-name (git-file-name "gnumach" version))
78 (sha256
79 (base32
80 "0q36z7k02bykrld90zaxbhyzxlmwlqqs4divgir6ix38zsp6icqk"))))
81 (build-system gnu-build-system)
82 (arguments
83 `(#:phases
84 (modify-phases %standard-phases
85 (replace 'install
86 (lambda _
87 (invoke "make" "install-data")))
88 (delete 'build))
0193c004 89
fb9d6f0f
EF
90 ;; GNU Mach supports only IA32 currently, so cheat so that we can at
91 ;; least install its headers.
92 ,@(if (%current-target-system)
93 '()
94 ;; See <http://lists.gnu.org/archive/html/bug-hurd/2015-06/msg00042.html>
95 ;; <http://lists.gnu.org/archive/html/guix-devel/2015-06/msg00716.html>
96 '(#:configure-flags '("--build=i586-pc-gnu"
97 "--host=i686-linux-gnu")))
0193c004 98
fb9d6f0f
EF
99 #:tests? #f))
100 (native-inputs
101 `(("autoconf" ,autoconf)
102 ("automake" ,automake)
103 ("texinfo" ,texinfo-4)))
104 (home-page "https://www.gnu.org/software/hurd/microkernel/mach/gnumach.html")
105 (synopsis "GNU Mach kernel headers")
106 (description
107 "Headers of the GNU Mach kernel.")
108 (license gpl2+))))
396b3c8b
MR
109
110(define-public mig
111 (package
112 (name "mig")
9c9402be 113 (version "1.8")
396b3c8b
MR
114 (source
115 (origin
116 (method url-fetch)
117 (uri (string-append "mirror://gnu/mig/mig-"
118 version ".tar.gz"))
119 (sha256
120 (base32
9c9402be 121 "1gyda8sq6b379nx01hkpbd85lz39irdvz2b9wbr63gicicx8i706"))))
396b3c8b 122 (build-system gnu-build-system)
a7ecc92d
MR
123 ;; Flex is needed both at build and run time.
124 (inputs `(("gnumach-headers" ,gnumach-headers)
125 ("flex" ,flex)))
396b3c8b
MR
126 (native-inputs
127 `(("flex" ,flex)
128 ("bison" ,bison)))
129 (arguments `(#:tests? #f))
6fd52309 130 (home-page "https://www.gnu.org/software/hurd/microkernel/mach/mig/gnu_mig.html")
396b3c8b
MR
131 (synopsis "Mach 3.0 interface generator for the Hurd")
132 (description
133 "GNU MIG is the GNU distribution of the Mach 3.0 interface generator
134MIG, as maintained by the GNU Hurd developers for the GNU project.
135You need this tool to compile the GNU Mach and GNU Hurd distributions,
35b9e423 136and to compile the GNU C library for the Hurd. Also, you will need it
396b3c8b
MR
137for other software in the GNU system that uses Mach-based inter-process
138communication.")
139 (license gpl2+)))
dc91c10f
MR
140
141(define-public hurd-headers
2d546858
LC
142 ;; Resort to a post-0.9 snapshot that provides the 'file_utimens' and
143 ;; 'file_exec_paths' RPCs that glibc 2.28 expects.
f379c665
MB
144 (let ((revision "1")
145 (commit "91a51672ff4cfe1f1a0712b4c542ded3081c825b"))
2d546858
LC
146 (package
147 (name "hurd-headers")
f379c665 148 (version (git-version "0.9" revision commit))
2d546858
LC
149 (source (origin
150 (method git-fetch)
151 (uri (git-reference
152 (url "https://git.savannah.gnu.org/git/hurd/hurd.git")
153 (commit commit)))
154 (sha256
155 (base32
f379c665 156 "16k9wkahz9wasviijz53n6i13nmiwa9fs64ikf1jqh8rl60hw7cz"))
2d546858
LC
157 (file-name (git-file-name name version))))
158 (build-system gnu-build-system)
159 (native-inputs
160 `(("mig" ,mig)
161 ("autoconf" ,autoconf)
162 ("automake" ,automake)))
163 (arguments
164 `(#:phases
165 (modify-phases %standard-phases
166 (replace 'install
167 (lambda _
168 (invoke "make" "install-headers" "no_deps=t")))
169 (delete 'build))
dc91c10f 170
2d546858
LC
171 #:configure-flags '( ;; Pretend we're on GNU/Hurd; 'configure' wants
172 ;; that.
173 ,@(if (%current-target-system)
174 '()
175 '("--host=i586-pc-gnu"))
176
177 ;; Reduce set of dependencies.
178 "--without-parted"
179 "--disable-ncursesw"
180 "--disable-test"
181 "--without-libbz2"
f379c665 182 "--without-libcrypt"
2d546858
LC
183 "--without-libz"
184 ;; Skip the clnt_create check because it expects
185 ;; a working glibc causing a circular dependency.
186 "ac_cv_search_clnt_create=no"
187
188 ;; Annihilate the checks for the 'file_exec_paths'
189 ;; & co. libc functions to avoid "link tests are
190 ;; not allowed after AC_NO_EXECUTABLES" error.
191 "ac_cv_func_file_exec_paths=no"
192 "ac_cv_func_exec_exec_paths=no"
193 "ac_cv_func__hurd_exec_paths=no"
194 "ac_cv_func_file_futimens=no")
195
196 #:tests? #f))
197 (home-page "https://www.gnu.org/software/hurd/hurd.html")
198 (synopsis "GNU Hurd headers")
199 (description
200 "This package provides C headers of the GNU Hurd, used to build the GNU C
dc91c10f 201Library and other user programs.")
2d546858 202 (license gpl2+))))
21a8fe1b
MR
203
204(define-public hurd-minimal
205 (package (inherit hurd-headers)
206 (name "hurd-minimal")
207 (inputs `(("glibc-hurd-headers" ,glibc/hurd-headers)))
21a8fe1b 208 (arguments
e1ecd50e
MR
209 (substitute-keyword-arguments (package-arguments hurd-headers)
210 ((#:phases _)
dc1d3cde
KK
211 '(modify-phases %standard-phases
212 (replace 'install
213 (lambda* (#:key outputs #:allow-other-keys)
214 (let ((out (assoc-ref outputs "out")))
215 ;; We need to copy libihash.a to the output directory manually,
216 ;; since there is no target for that in the makefile.
217 (mkdir-p (string-append out "/include"))
218 (copy-file "libihash/ihash.h"
219 (string-append out "/include/ihash.h"))
220 (mkdir-p (string-append out "/lib"))
221 (copy-file "libihash/libihash.a"
222 (string-append out "/lib/libihash.a"))
223 #t)))
224 (replace 'build
225 (lambda _
2d546858
LC
226 ;; Install <assert-backtrace.h> & co.
227 (invoke "make" "-Clibshouldbeinlibc"
228 "../include/assert-backtrace.h")
229
230 ;; Build libihash.
a48d22d6 231 (invoke "make" "-Clibihash" "libihash.a")))))))
6fd52309 232 (home-page "https://www.gnu.org/software/hurd/hurd.html")
21a8fe1b
MR
233 (synopsis "GNU Hurd libraries")
234 (description
a124bbd2 235 "This package provides libihash, needed to build the GNU C
21a8fe1b
MR
236Library for GNU/Hurd.")
237 (license gpl2+)))
38efbcbb
MR
238
239(define-public hurd-core-headers
240 (package
241 (name "hurd-core-headers")
242 (version (package-version hurd-headers))
243 (source #f)
244 (build-system trivial-build-system)
245 (arguments
246 '(#:modules ((guix build union))
247 #:builder (begin
248 (use-modules (ice-9 match)
249 (guix build union))
250 (match %build-inputs
251 (((names . directories) ...)
252 (union-build (assoc-ref %outputs "out")
e3cfef22
MW
253 directories)
254 #t)))))
38efbcbb
MR
255 (inputs `(("gnumach-headers" ,gnumach-headers)
256 ("hurd-headers" ,hurd-headers)
257 ("hurd-minimal" ,hurd-minimal)))
258 (synopsis "Union of the Hurd headers and libraries")
259 (description
260 "This package contains the union of the Mach and Hurd headers and the
261Hurd-minimal package which are needed for both glibc and GCC.")
262 (home-page (package-home-page hurd-headers))
263 (license (package-license hurd-headers))))
8df672aa
MR
264
265(define-public gnumach
266 (package
fb9d6f0f 267 (inherit gnumach-headers)
8df672aa 268 (name "gnumach")
8df672aa 269 (arguments
e62f6f77 270 (substitute-keyword-arguments (package-arguments gnumach-headers)
29814639
LC
271 ((#:configure-flags flags ''())
272 `(cons "--enable-kdb" ,flags)) ;enable kernel debugger
e62f6f77
LC
273 ((#:phases phases '%standard-phases)
274 `(modify-phases %standard-phases
275 (add-after 'install 'produce-image
276 (lambda* (#:key outputs #:allow-other-keys)
277 (let* ((out (assoc-ref outputs "out"))
278 (boot (string-append out "/boot")))
279 (invoke "make" "gnumach.gz")
280 (install-file "gnumach.gz" boot)
281 #t)))))))
8df672aa
MR
282 (native-inputs
283 `(("mig" ,mig)
e62f6f77
LC
284 ("perl" ,perl)
285 ("autoconf" ,autoconf)
286 ("automake" ,automake)
287 ("texinfo" ,texinfo-4)))
8df672aa 288 (supported-systems (cons "i686-linux" %hurd-systems))
8df672aa
MR
289 (synopsis "Microkernel of the GNU system")
290 (description
fb9d6f0f 291 "GNU Mach is the microkernel upon which a GNU Hurd system is based.")))
cc4faa35 292
f46cf8ef
LC
293(define (hurd-rc-script)
294 "Return a script to be installed as /libexec/rc in the 'hurd' package. The
295script takes care of installing the relevant passive translators on the first
296boot, since this cannot be done from GNU/Linux."
297 (define translators
298 '(("/servers/crash-dump-core" ("/hurd/crash" "--dump-core"))
299 ("/servers/crash-kill" ("/hurd/crash" "--kill"))
300 ("/servers/crash-suspend" ("/hurd/crash" "--suspend"))
301 ("/servers/password" ("/hurd/password"))
302 ("/servers/socket/1" ("/hurd/pflocal"))
303 ("/servers/socket/2" ("/hurd/pfinet" "--interface" "eth0"
304 "--address" "10.0.2.77"
305 "--netmask" "255.255.255.0"
306 "--gateway" "10.0.2.2"
307 "--ipv6" "/servers/socket/16"))))
308
309 (define rc
310 (with-imported-modules '((guix build utils))
311 #~(begin
312 (use-modules (guix build utils)
313 (ice-9 match))
314
315 ;; "@HURD@" is a placeholder.
316 (setenv "PATH" "@HURD@/bin")
317
318 (define (translated? node)
319 ;; Return true if a translator is installed on NODE.
320 (with-output-to-port (%make-void-port "w")
321 (lambda ()
322 (with-error-to-port (%make-void-port "w")
323 (lambda ()
324 (zero? (system* "showtrans" "-s" node)))))))
325
326 (for-each (match-lambda
327 ((node command)
328 (unless (translated? node)
329 (mkdir-p (dirname node))
330 (apply invoke "settrans" "-c" node command))))
331 '#$translators))))
332
333 ;; FIXME: We want the program to use the cross-compiled Guile when
334 ;; cross-compiling. But why do we need to be explicit here?
335 (with-parameters ((%current-target-system "i586-pc-gnu"))
336 (program-file "rc" rc)))
337
cc4faa35
MR
338(define-public hurd
339 (package
340 (name "hurd")
496d607d
JN
341 (version (package-version hurd-headers))
342 (source (origin (inherit (package-source hurd-headers))
343 (patches (search-patches "hurd-cross.patch"))))
cc4faa35
MR
344 (arguments
345 `(#:phases
346 (modify-phases %standard-phases
347 (add-before 'build 'pre-build
f46cf8ef
LC
348 (lambda _
349 ;; Don't change the ownership of any file at this time.
350 (substitute* '("daemons/Makefile" "utils/Makefile")
351 (("-o root -m 4755") ""))
352 #t))
b7e23a92
LC
353 (add-before 'build 'set-file-names
354 (lambda* (#:key inputs outputs #:allow-other-keys)
29505c7d
LC
355 (let* ((out (assoc-ref outputs "out"))
356 (bash (assoc-ref inputs "bash-minimal"))
357 (coreutils (assoc-ref inputs "coreutils"))
358 (sed (assoc-ref inputs "sed"))
359 (grep (assoc-ref inputs "grep"))
360 (util-linux (assoc-ref inputs "util-linux")))
361 (substitute* '("daemons/runttys.c" "daemons/getty.c" "utils/login.c")
b7e23a92 362 (("/bin/login")
29505c7d
LC
363 (string-append out "/bin/login"))
364 (("/bin/bash") (string-append bash "/bin/bash")))
365 (substitute* '("startup/startup.c" "init/init.c" "config/ttys")
366 (("/libexec/")
367 (string-append out "/libexec/")))
368 (substitute* "daemons/console-run.c"
369 (("/hurd/")
370 (string-append out "/hurd/")))
371
372 (substitute* '("daemons/runsystem.sh"
373 "daemons/runsystem.hurd.sh"
374 "sutils/MAKEDEV.sh")
375 (("^PATH=.*")
376 (string-append "PATH=" out "/bin:" out "/sbin:"
377 coreutils "/bin:"
378 sed "/bin:" grep "/bin:"
379 util-linux "/bin\n"))
380 (("^SHELL=.*")
381 (string-append "SHELL=" bash "/bin/bash\n"))
382 (("/sbin/") (string-append out "/sbin/"))
383 (("/libexec/") (string-append out "/libexec/"))
384 (("/hurd/") (string-append out "/hurd/")))
385
386 (substitute* "daemons/runsystem.sh"
387 (("export PATH")
388 (string-append "export PATH\n"
389 "\
390fsysopts / --writable
391
392# MAKEDEV relies on pipes so this needs to be set up.
393settrans -c /servers/socket/1 /hurd/pflocal
394
395(cd /dev; MAKEDEV -D /dev std vcs tty{1,2,3,4,5,6})\n")))
396
397 (substitute* "daemons/runsystem.hurd.sh"
398 (("export PATH")
399 "export PATH
400fsysopts / --writable\n"))
401 #t)))
402 (add-after 'patch-shebangs 'patch-libexec-shebangs
403 (lambda* (#:key inputs outputs #:allow-other-keys)
404 ;; XXX: Since the 'patch-shebangs' phase doesn't traverse
405 ;; /libexec, do it here.
406 (let* ((out (assoc-ref outputs "out"))
407 (bash (assoc-ref inputs "bash-minimal"))
408 (path (list (string-append bash "/bin"))))
409 (for-each (lambda (file)
410 (patch-shebang file path))
411 (find-files (string-append out "/libexec")))
b7e23a92 412 #t)))
62a3bbfd
LC
413 (add-after 'install 'install-goodies
414 (lambda* (#:key outputs #:allow-other-keys)
415 ;; Install additional goodies.
416 ;; TODO: Build & install *.msgids for rpctrace.
417 (let ((out (assoc-ref outputs "out")))
418 ;; Install the fancy UTF-8 motd.
419 (mkdir-p (string-append out "/etc"))
420 (copy-file "console/motd.UTF8"
421 (string-append out "/etc/motd"))
422 #t)))
f46cf8ef
LC
423 (add-after 'install 'install-rc-file
424 (lambda* (#:key inputs outputs #:allow-other-keys)
425 (let* ((out (assoc-ref outputs "out"))
426 (file (string-append out "/libexec/rc"))
427 (rc (assoc-ref inputs "hurd-rc")))
428 (delete-file file)
429 (copy-file rc file)
430 (substitute* file
431 (("@HURD@") out))
432 #t))))
cc4faa35
MR
433 #:configure-flags (list (string-append "LDFLAGS=-Wl,-rpath="
434 %output "/lib")
435 "--disable-ncursesw"
436 "--without-libbz2"
437 "--without-libz"
438 "--without-parted")))
439 (build-system gnu-build-system)
f46cf8ef
LC
440 (inputs
441 `(("glibc-hurd-headers" ,glibc/hurd-headers)
29505c7d
LC
442 ("hurd-rc" ,(hurd-rc-script))
443
abbeaf54 444 ("libgcrypt" ,libgcrypt) ;for /hurd/random
29505c7d
LC
445 ;; Tools for the /libexec/* scripts.
446 ("bash-minimal" ,bash-minimal)
447 ("coreutils" ,coreutils)
448 ("sed" ,sed)
449 ("grep" ,grep)
450 ("util-linux" ,util-linux)))
cc4faa35 451 (native-inputs
496d607d
JN
452 `(("autoconf" ,autoconf)
453 ("automake" ,automake)
abbeaf54 454 ("libgcrypt" ,libgcrypt) ;for 'libgcrypt-config'
09ac892a
LC
455 ("mig" ,(if (%current-target-system)
456 ;; XXX: When targeting i586-pc-gnu, we need a 32-bit MiG,
457 ;; hence this hack.
458 (package
459 (inherit mig)
460 (arguments `(#:system "i686-linux")))
461 mig))
496d607d
JN
462 ("perl" ,perl)
463 ("texinfo" ,texinfo-4)))
cc4faa35
MR
464 (supported-systems %hurd-systems)
465 (home-page "https://www.gnu.org/software/hurd/hurd.html")
466 (synopsis "The kernel servers for the GNU operating system")
467 (description
468 "The Hurd is the kernel for the GNU system, a replacement and
469augmentation of standard Unix kernels. It is a collection of protocols for
470system interaction (file systems, networks, authentication), and servers
471implementing them.")
472 (license gpl2+)))