1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014, 2015, 2016, 2017 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
3 ;;; Copyright © 2018, 2020 Ludovic Courtès <ludo@gnu.org>
4 ;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
5 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
6 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
8 ;;; This file is part of GNU Guix.
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.
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.
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/>.
23 (define-module (gnu packages hurd)
24 #:use-module (guix licenses)
25 #:use-module (guix download)
26 #:use-module (guix packages)
27 #:use-module (gnu packages)
28 #:use-module (guix gexp)
29 #:use-module (guix utils)
30 #:use-module (guix build-system gnu)
31 #:use-module (guix build-system trivial)
32 #:use-module (gnu packages autotools)
33 #:use-module (gnu packages flex)
34 #:use-module (gnu packages bison)
35 #:use-module (gnu packages perl)
36 #:use-module (gnu packages base)
37 #:use-module (gnu packages texinfo)
38 #:use-module (guix git-download)
39 #:export (hurd-system?
43 (define (hurd-triplet? triplet)
44 (and (string-suffix? "-gnu" triplet)
45 (not (string-contains triplet "linux"))))
47 (define (hurd-target?)
48 "Return true if the cross-compilation target or the current system is
50 (or (and=> (%current-target-system) hurd-triplet?)
51 (and (not (%current-target-system))
52 (and=> (%current-system) hurd-triplet?))))
54 (define (hurd-system?)
55 "Return true if the current system is the Hurd."
56 (and=> (%current-system) hurd-triplet?))
58 (define (hurd-source-url version)
59 (string-append "mirror://gnu/hurd/hurd-"
62 (define-public gnumach-headers
63 (let ((commit "097f9cf735ffa1212b828682ad92f0f6c5f1c552")
66 (name "gnumach-headers")
67 (version (git-version "1.8" revision commit))
72 (url "https://git.savannah.gnu.org/git/hurd/gnumach.git")
74 (file-name (git-file-name "gnumach" version))
77 "0q36z7k02bykrld90zaxbhyzxlmwlqqs4divgir6ix38zsp6icqk"))))
78 (build-system gnu-build-system)
81 (modify-phases %standard-phases
84 (invoke "make" "install-data")))
87 ;; GNU Mach supports only IA32 currently, so cheat so that we can at
88 ;; least install its headers.
89 ,@(if (%current-target-system)
91 ;; See <http://lists.gnu.org/archive/html/bug-hurd/2015-06/msg00042.html>
92 ;; <http://lists.gnu.org/archive/html/guix-devel/2015-06/msg00716.html>
93 '(#:configure-flags '("--build=i586-pc-gnu"
94 "--host=i686-linux-gnu")))
98 `(("autoconf" ,autoconf)
99 ("automake" ,automake)
100 ("texinfo" ,texinfo-4)))
101 (home-page "https://www.gnu.org/software/hurd/microkernel/mach/gnumach.html")
102 (synopsis "GNU Mach kernel headers")
104 "Headers of the GNU Mach kernel.")
114 (uri (string-append "mirror://gnu/mig/mig-"
118 "1gyda8sq6b379nx01hkpbd85lz39irdvz2b9wbr63gicicx8i706"))))
119 (build-system gnu-build-system)
120 ;; Flex is needed both at build and run time.
121 (inputs `(("gnumach-headers" ,gnumach-headers)
126 (arguments `(#:tests? #f))
127 (home-page "https://www.gnu.org/software/hurd/microkernel/mach/mig/gnu_mig.html")
128 (synopsis "Mach 3.0 interface generator for the Hurd")
130 "GNU MIG is the GNU distribution of the Mach 3.0 interface generator
131 MIG, as maintained by the GNU Hurd developers for the GNU project.
132 You need this tool to compile the GNU Mach and GNU Hurd distributions,
133 and to compile the GNU C library for the Hurd. Also, you will need it
134 for other software in the GNU system that uses Mach-based inter-process
138 (define-public hurd-headers
139 ;; Resort to a post-0.9 snapshot that provides the 'file_utimens' and
140 ;; 'file_exec_paths' RPCs that glibc 2.28 expects.
142 (commit "91a51672ff4cfe1f1a0712b4c542ded3081c825b"))
144 (name "hurd-headers")
145 (version (git-version "0.9" revision commit))
149 (url "https://git.savannah.gnu.org/git/hurd/hurd.git")
153 "16k9wkahz9wasviijz53n6i13nmiwa9fs64ikf1jqh8rl60hw7cz"))
154 (file-name (git-file-name name version))))
155 (build-system gnu-build-system)
158 ("autoconf" ,autoconf)
159 ("automake" ,automake)))
162 (modify-phases %standard-phases
165 (invoke "make" "install-headers" "no_deps=t")))
168 #:configure-flags '( ;; Pretend we're on GNU/Hurd; 'configure' wants
170 ,@(if (%current-target-system)
172 '("--host=i586-pc-gnu"))
174 ;; Reduce set of dependencies.
181 ;; Skip the clnt_create check because it expects
182 ;; a working glibc causing a circular dependency.
183 "ac_cv_search_clnt_create=no"
185 ;; Annihilate the checks for the 'file_exec_paths'
186 ;; & co. libc functions to avoid "link tests are
187 ;; not allowed after AC_NO_EXECUTABLES" error.
188 "ac_cv_func_file_exec_paths=no"
189 "ac_cv_func_exec_exec_paths=no"
190 "ac_cv_func__hurd_exec_paths=no"
191 "ac_cv_func_file_futimens=no")
194 (home-page "https://www.gnu.org/software/hurd/hurd.html")
195 (synopsis "GNU Hurd headers")
197 "This package provides C headers of the GNU Hurd, used to build the GNU C
198 Library and other user programs.")
201 (define-public hurd-minimal
202 (package (inherit hurd-headers)
203 (name "hurd-minimal")
204 (inputs `(("glibc-hurd-headers" ,glibc/hurd-headers)))
206 (substitute-keyword-arguments (package-arguments hurd-headers)
208 '(modify-phases %standard-phases
210 (lambda* (#:key outputs #:allow-other-keys)
211 (let ((out (assoc-ref outputs "out")))
212 ;; We need to copy libihash.a to the output directory manually,
213 ;; since there is no target for that in the makefile.
214 (mkdir-p (string-append out "/include"))
215 (copy-file "libihash/ihash.h"
216 (string-append out "/include/ihash.h"))
217 (mkdir-p (string-append out "/lib"))
218 (copy-file "libihash/libihash.a"
219 (string-append out "/lib/libihash.a"))
223 ;; Install <assert-backtrace.h> & co.
224 (invoke "make" "-Clibshouldbeinlibc"
225 "../include/assert-backtrace.h")
228 (invoke "make" "-Clibihash" "libihash.a")))))))
229 (home-page "https://www.gnu.org/software/hurd/hurd.html")
230 (synopsis "GNU Hurd libraries")
232 "This package provides libihash, needed to build the GNU C
233 Library for GNU/Hurd.")
236 (define-public hurd-core-headers
238 (name "hurd-core-headers")
239 (version (package-version hurd-headers))
241 (build-system trivial-build-system)
243 '(#:modules ((guix build union))
245 (use-modules (ice-9 match)
248 (((names . directories) ...)
249 (union-build (assoc-ref %outputs "out")
252 (inputs `(("gnumach-headers" ,gnumach-headers)
253 ("hurd-headers" ,hurd-headers)
254 ("hurd-minimal" ,hurd-minimal)))
255 (synopsis "Union of the Hurd headers and libraries")
257 "This package contains the union of the Mach and Hurd headers and the
258 Hurd-minimal package which are needed for both glibc and GCC.")
259 (home-page (package-home-page hurd-headers))
260 (license (package-license hurd-headers))))
262 (define-public gnumach
264 (inherit gnumach-headers)
267 (substitute-keyword-arguments (package-arguments gnumach-headers)
268 ((#:configure-flags flags ''())
269 `(cons "--enable-kdb" ,flags)) ;enable kernel debugger
270 ((#:phases phases '%standard-phases)
271 `(modify-phases %standard-phases
272 (add-after 'install 'produce-image
273 (lambda* (#:key outputs #:allow-other-keys)
274 (let* ((out (assoc-ref outputs "out"))
275 (boot (string-append out "/boot")))
276 (invoke "make" "gnumach.gz")
277 (install-file "gnumach.gz" boot)
282 ("autoconf" ,autoconf)
283 ("automake" ,automake)
284 ("texinfo" ,texinfo-4)))
285 (supported-systems (cons "i686-linux" %hurd-systems))
286 (synopsis "Microkernel of the GNU system")
288 "GNU Mach is the microkernel upon which a GNU Hurd system is based.")))
290 (define (hurd-rc-script)
291 "Return a script to be installed as /libexec/rc in the 'hurd' package. The
292 script takes care of installing the relevant passive translators on the first
293 boot, since this cannot be done from GNU/Linux."
295 '(("/servers/crash-dump-core" ("/hurd/crash" "--dump-core"))
296 ("/servers/crash-kill" ("/hurd/crash" "--kill"))
297 ("/servers/crash-suspend" ("/hurd/crash" "--suspend"))
298 ("/servers/password" ("/hurd/password"))
299 ("/servers/socket/1" ("/hurd/pflocal"))
300 ("/servers/socket/2" ("/hurd/pfinet" "--interface" "eth0"
301 "--address" "10.0.2.77"
302 "--netmask" "255.255.255.0"
303 "--gateway" "10.0.2.2"
304 "--ipv6" "/servers/socket/16"))))
307 (with-imported-modules '((guix build utils))
309 (use-modules (guix build utils)
312 ;; "@HURD@" is a placeholder.
313 (setenv "PATH" "@HURD@/bin")
315 (define (translated? node)
316 ;; Return true if a translator is installed on NODE.
317 (with-output-to-port (%make-void-port "w")
319 (with-error-to-port (%make-void-port "w")
321 (zero? (system* "showtrans" "-s" node)))))))
323 (for-each (match-lambda
325 (unless (translated? node)
326 (mkdir-p (dirname node))
327 (apply invoke "settrans" "-c" node command))))
330 ;; FIXME: We want the program to use the cross-compiled Guile when
331 ;; cross-compiling. But why do we need to be explicit here?
332 (with-parameters ((%current-target-system "i586-pc-gnu"))
333 (program-file "rc" rc)))
338 (version (package-version hurd-headers))
339 (source (origin (inherit (package-source hurd-headers))
340 (patches (search-patches "hurd-cross.patch"))))
343 (modify-phases %standard-phases
344 (add-before 'build 'pre-build
346 ;; Don't change the ownership of any file at this time.
347 (substitute* '("daemons/Makefile" "utils/Makefile")
348 (("-o root -m 4755") ""))
350 (add-after 'install 'install-rc-file
351 (lambda* (#:key inputs outputs #:allow-other-keys)
352 (let* ((out (assoc-ref outputs "out"))
353 (file (string-append out "/libexec/rc"))
354 (rc (assoc-ref inputs "hurd-rc")))
360 #:configure-flags (list (string-append "LDFLAGS=-Wl,-rpath="
365 "--without-parted")))
366 (build-system gnu-build-system)
368 `(("glibc-hurd-headers" ,glibc/hurd-headers)
369 ("hurd-rc" ,(hurd-rc-script))))
371 `(("autoconf" ,autoconf)
372 ("automake" ,automake)
375 ("texinfo" ,texinfo-4)))
376 (supported-systems %hurd-systems)
377 (home-page "https://www.gnu.org/software/hurd/hurd.html")
378 (synopsis "The kernel servers for the GNU operating system")
380 "The Hurd is the kernel for the GNU system, a replacement and
381 augmentation of standard Unix kernels. It is a collection of protocols for
382 system interaction (file systems, networks, authentication), and servers