projects/guix·blob java-team · refs

1067 lines · 46.1 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014, 2015, 2016, 2017 Manolis Fragkiskos Ragkousis <[email protected]>
3;;; Copyright © 2018, 2020-2024 Ludovic Courtès <[email protected]>
4;;; Copyright © 2020 Efraim Flashner <[email protected]>
5;;; Copyright © 2020 Marius Bakke <[email protected]>
6;;; Copyright © 2020, 2022, 2023, 2024, 2026 Janneke Nieuwenhuizen <[email protected]>
7;;; Copyright © 2020 Ricardo Wurmus <[email protected]>
8;;; Copyright © 2020 Rene Saavedra <[email protected]>
9;;; Copyright © 2023 Josselin Poiret <[email protected]>
10;;; Copyright © 2025 Yelninei <[email protected]>
11;;;
12;;; This file is part of GNU Guix.
13;;;
14;;; GNU Guix is free software; you can redistribute it and/or modify it
15;;; under the terms of the GNU General Public License as published by
16;;; the Free Software Foundation; either version 3 of the License, or (at
17;;; your option) any later version.
18;;;
19;;; GNU Guix is distributed in the hope that it will be useful, but
20;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22;;; GNU General Public License for more details.
23;;;
24;;; You should have received a copy of the GNU General Public License
25;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26
27(define-module (gnu packages hurd)
28 #:use-module ((guix licenses) #:hide (zlib))
29 #:use-module (guix download)
30 #:use-module (guix packages)
31 #:use-module (gnu packages)
32 #:use-module (guix gexp)
33 #:use-module (guix utils)
34 #:use-module (guix build-system gnu)
35 #:use-module (guix build-system trivial)
36 #:use-module (gnu packages autotools)
37 #:use-module (gnu packages compression)
38 #:use-module (gnu packages cross-base)
39 #:use-module (gnu packages crypto)
40 #:use-module (gnu packages disk)
41 #:use-module (gnu packages compiler-tools)
42 #:use-module (gnu packages gawk)
43 #:use-module (gnu packages gnupg)
44 #:use-module (gnu packages bison)
45 #:use-module (gnu packages libdaemon)
46 #:use-module (gnu packages linux)
47 #:use-module (gnu packages perl)
48 #:use-module (gnu packages pkg-config)
49 #:use-module (gnu packages base)
50 #:use-module (gnu packages bash)
51 #:use-module (gnu packages texinfo)
52 #:use-module (gnu packages onc-rpc)
53 #:use-module (gnu packages xorg) ;libpciaccess
54 #:use-module (guix git-download)
55 #:use-module (ice-9 match))
56
57(define (hurd-source-url version)
58 (string-append "mirror://gnu/hurd/hurd-"
59 version ".tar.gz"))
60
61(define-public gnumach-headers
62 (package
63 (name "gnumach-headers")
64 (version "1.8+git20260224")
65 (source
66 (origin
67 (method git-fetch)
68 (uri (git-reference
69 (url "https://git.savannah.gnu.org/git/hurd/gnumach.git")
70 (commit (string-append "v" version))))
71 (patches (search-patches "gnumach-version.patch"))
72 (file-name (git-file-name "gnumach" version))
73 (sha256
74 (base32 "08s3a8fr4pax66n3v2darjzi2vgab30k1siqq9djdaa0r0ssnai8"))))
75 (build-system gnu-build-system)
76 (arguments
77 `(#:phases
78 (modify-phases %standard-phases
79 (replace 'install
80 (lambda _
81 (invoke "make" "install-data" "install-data-hook")))
82 (delete 'build))
83 #:tests? #f))
84 (native-inputs
85 (list autoconf automake texinfo))
86 (supported-systems %hurd-systems)
87 (home-page "https://www.gnu.org/software/hurd/microkernel/mach/gnumach.html")
88 (synopsis "GNU Mach kernel headers")
89 (description
90 "Headers of the GNU Mach kernel.")
91 (license gpl2+)))
92
93(define-public mig
94 (let ((revision "1")
95 (commit "3f4b0062963fca5d90fc65c1d7912ecdc21a8fed"))
96 (package
97 (name "mig")
98 (version (git-version "1.8+git20231217" revision commit))
99 (source (origin
100 (method git-fetch)
101 (uri (git-reference
102 (url "https://git.savannah.gnu.org/git/hurd/mig.git")
103 (commit commit)))
104 (file-name (git-file-name name version))
105 (sha256
106 (base32
107 "0fj5vwl93z0wmy20x6cs2av2c956w0k8glqsc8dzb3s8km7j7akq"))))
108 (build-system gnu-build-system)
109 ;; Flex is needed both at build and run time.
110 (inputs (list gnumach-headers flex))
111 (native-inputs (list autoconf automake flex bison))
112 (arguments
113 (list #:tests? #f
114 #:phases
115 #~(modify-phases %standard-phases
116 (add-after 'install 'avoid-perl-dependency
117 (lambda* (#:key build inputs outputs #:allow-other-keys)
118 (let* ((out (assoc-ref outputs "out"))
119 (bin (string-append out "/bin")))
120 ;; By default 'mig' (or 'TARGET-mig') uses Perl to
121 ;; compute 'libexecdir_rel'. Avoid it.
122 (substitute* (find-files bin "mig$")
123 (("^libexecdir_rel=.*")
124 "libexecdir_rel=../libexec\n"))))))))
125 (home-page "https://www.gnu.org/software/hurd/microkernel/mach/mig/gnu_mig.html")
126 (synopsis "Mach 3.0 interface generator for the Hurd")
127 (description
128 "GNU MIG is the GNU distribution of the Mach 3.0 interface generator
129MIG, as maintained by the GNU Hurd developers for the GNU project.
130You need this tool to compile the GNU Mach and GNU Hurd distributions,
131and to compile the GNU C library for the Hurd. Also, you will need it
132for other software in the GNU system that uses Mach-based inter-process
133communication.")
134 (license gpl2+))))
135
136(define-public hurd-headers
137 (let ((commit "6290b4cf92963f64ffa447cdaba099812c80fbfb")
138 (revision "0"))
139 (package
140 (name "hurd-headers")
141 (version (git-version "0.9.git20251029" revision commit))
142 (source (origin
143 (method git-fetch)
144 (uri (git-reference
145 (url "https://git.savannah.gnu.org/git/hurd/hurd.git")
146 (commit commit)))
147 (sha256
148 (base32
149 "0lkmxw2016isb80k8pjjr64il6irgwsqgd3634f79bry2fabhbdj"))
150 (file-name (git-file-name name version))))
151 (build-system gnu-build-system)
152 (native-inputs
153 (list autoconf
154 automake
155 (if (%current-target-system)
156 (cross-mig (%current-target-system))
157 mig)))
158 (arguments
159 `(#:phases
160 (modify-phases %standard-phases
161 (replace 'install
162 (lambda _
163 (invoke "make" "install-headers" "no_deps=t")))
164 (delete 'build))
165
166 #:configure-flags '( ;; Reduce set of dependencies.
167 "--without-parted"
168 "--disable-ncursesw"
169 "--disable-test"
170 "--without-libbz2"
171 "--without-libcrypt"
172 "--without-libz"
173 "--without-rump"
174 ;; Skip the clnt_create check because it expects
175 ;; a working glibc causing a circular dependency.
176 "ac_cv_search_clnt_create=no"
177
178 ;; Annihilate the checks for the 'file_exec_paths'
179 ;; & co. libc functions to avoid "link tests are
180 ;; not allowed after AC_NO_EXECUTABLES" error.
181 "ac_cv_func_file_exec_paths=no"
182 "ac_cv_func_exec_exec_paths=no"
183 "ac_cv_func__hurd_exec_paths=no"
184 "ac_cv_func__hurd_libc_proc_init=no"
185 "ac_cv_func_mach_port_set_ktype=no"
186 "ac_cv_func_file_futimens=no"
187 "ac_cv_func_file_utimens=no"
188 "ac_cv_lib_acpica_acpi_init=no")
189
190 #:tests? #f))
191 (supported-systems %hurd-systems)
192 (home-page "https://www.gnu.org/software/hurd/hurd.html")
193 (synopsis "GNU Hurd headers")
194 (description
195 "This package provides C headers of the GNU Hurd, used to build the GNU C
196Library and other user programs.")
197 (license gpl2+))))
198
199(define-public hurd-minimal
200 (package (inherit hurd-headers)
201 (name "hurd-minimal")
202 (inputs (list glibc/hurd-headers gnumach-headers))
203 (arguments
204 (substitute-keyword-arguments arguments
205 ((#:make-flags flags '())
206 #~'(#$(string-append "lib-subdirs=libshouldbeinlibc libihash libstore")
207 "prog-subdirs="
208 "other-subdirs="
209 #$@flags))
210 ((#:phases _)
211 #~%standard-phases)
212 ((#:validate-runpath? validate-runpath? #f)
213 #f)))
214 (supported-systems %hurd-systems)
215 (home-page "https://www.gnu.org/software/hurd/hurd.html")
216 (synopsis "GNU Hurd libraries")
217 (description
218 "This package provides libshouldbeinlibc, libihash, libstore, libports,
219libiohelp, libfshelp, libtrivfs, and libmachdev, needed to build the GNU C
220Library, Parted and netdde for GNU/Hurd.")
221 (license gpl2+)))
222
223(define-public libirqhelp
224 (package (inherit hurd-headers)
225 (name "libirqhelp")
226 (arguments
227 (substitute-keyword-arguments arguments
228 ((#:make-flags flags '())
229 #~'(#$(string-append "lib-subdirs=libirqhelp")
230 "prog-subdirs="
231 "other-subdirs="
232 #$@flags))
233 ((#:phases _)
234 #~%standard-phases)))
235 (supported-systems %hurd-systems)
236 (synopsis "Hurd helper library for userspace IRQ handling")
237 (description
238 "This package provides libirqhelp, a GNU Hurd helper library to handle
239@acronym{IRQs, interrupt requests} in user space.")
240 (license gpl2+)))
241
242(define-public hurd-core-headers
243 (package
244 (name "hurd-core-headers")
245 (version (package-version hurd-headers))
246 (source #f)
247 (build-system trivial-build-system)
248 (arguments
249 '(#:modules ((guix build union))
250 #:builder (begin
251 (use-modules (srfi srfi-1)
252 (srfi srfi-26)
253 (ice-9 match)
254 (guix build union))
255 (let ((inputs (filter
256 (compose (cute member <> '("gnumach-headers"
257 "hurd-headers"
258 "hurd-minimal"))
259 car)
260 %build-inputs)))
261 (match inputs
262 (((names . directories) ...)
263 (union-build (assoc-ref %outputs "out")
264 directories)
265 #t))))))
266 (inputs (list gnumach-headers hurd-headers hurd-minimal))
267 (supported-systems %hurd-systems)
268 (synopsis "Union of the Hurd headers and libraries")
269 (description
270 "This package contains the union of the Mach and Hurd headers and the
271Hurd-minimal package which are needed for both glibc and GCC.")
272 (home-page (package-home-page hurd-headers))
273 (license (package-license hurd-headers))))
274
275(define-public gnumach
276 (package
277 (inherit gnumach-headers)
278 (name "gnumach")
279 (arguments
280 (substitute-keyword-arguments arguments
281 ((#:configure-flags flags ''())
282 `(cons* "--enable-kdb" ;enable kernel debugger
283 "--disable-net-group"
284 "--disable-pcmcia-group"
285 "--disable-wireless-group"
286 ,flags))
287 ((#:phases phases '%standard-phases)
288 #~(modify-phases %standard-phases
289 (add-after 'install 'produce-image
290 (lambda _
291 (let ((boot (string-append #$output "/boot")))
292 (invoke "make" "gnumach.gz")
293 (install-file "gnumach.gz" boot))))))))
294 (native-inputs
295 (list autoconf
296 automake
297 (if (%current-target-system)
298 (cross-mig (%current-target-system))
299 mig)
300 perl
301 texinfo))
302 (supported-systems `("i686-linux" ,@%hurd-systems))
303 (synopsis "Microkernel of the GNU system")
304 (description
305 "GNU Mach is the microkernel upon which a GNU Hurd system is based.")))
306
307(define unifont
308 ;; GNU Unifont, <http://gnu.org/s/unifont>.
309 ;; Used the the VGA driver of the Hurd's console client.
310 (origin
311 (method url-fetch)
312 (uri
313 "http://unifoundry.com/pub/unifont-7.0.06/font-builds/unifont-7.0.06.bdf.gz")
314 (sha256
315 (base32
316 "0p2vhnc18cnbmb39vq4m7hzv4mhnm2l0a2s7gx3ar277fwng3hys"))))
317
318(define dde-sources
319 ;; This is the current tip of the dde branch
320 (let ((commit "b6c8526c703f3ba76294d9002f195c63897ec661"))
321 (origin
322 (method git-fetch)
323 (uri (git-reference
324 (url "https://git.savannah.gnu.org/git/hurd/incubator.git")
325 (commit commit)))
326 (sha256
327 (base32
328 "0k1ilj8ghli8x43xaksbc4y419pqh0w16k374914c07svq419bbr"))
329 (file-name (git-file-name "dde" (string-take commit 7))))))
330
331(define %import-from-dde
332 (list "libmachdevdde" "libddekit" "libdde_linux26"))
333
334(define %add-to-hurd-subdirs
335 (list "libmachdevdde" "libddekit"))
336
337(define-public libacpica
338 (let ((commit "0c3593e27947ef0734a070143caadaed28438354")
339 (revision "0"))
340 (package
341 (name "libacpica")
342 (home-page "https://salsa.debian.org/hurd-team/libacpica")
343 (version (git-version "20220331" revision commit))
344 (source (origin
345 (method git-fetch)
346 (uri (git-reference
347 (url home-page)
348 (commit commit)))
349 (sha256
350 (base32
351 "0hyfg4w2ch6a833kkxjcsddqq2712gqlbvrl6zv5yzvallpfzh7d"))
352 (file-name (git-file-name name version))))
353 (arguments
354 (list
355 #:tests? #f ;no tests
356 #:modules '((srfi srfi-26)
357 (ice-9 rdelim)
358 (guix build utils)
359 (guix build gnu-build-system))
360 #:make-flags #~`(,(string-append "CC=" #$(cc-for-target))
361 ,(string-append "PREFIX=" #$output))
362 ;; As we are using the Debian package as upstream, we follow their
363 ;; build:
364 ;; * apply patches in debian/patches taken from the
365 ;; debian/patches/series file
366 #:phases
367 #~(modify-phases %standard-phases
368 (delete 'configure)
369 (add-after 'unpack 'apply-patches
370 (lambda* (#:key target #:allow-other-keys)
371 (let* ((patch-directory "debian/patches/")
372 (series (string-append patch-directory "series"))
373 (text (with-input-from-file series read-string))
374 (lines (string-split (string-trim-right text) #\newline))
375 (patches (filter (negate (cute string-prefix? "#" <>))
376 lines))
377 (patch-files (map
378 (cute string-append patch-directory <>)
379 patches)))
380 (for-each
381 (cute invoke "patch" "--force" "-p1" "-i" <>)
382 patch-files)))))))
383 (inputs (list libirqhelp
384 libpciaccess))
385 (build-system gnu-build-system)
386 (supported-systems %hurd-systems)
387 (synopsis "ACPICA as a library")
388 (description "libacpica provides ACPICA as a library.")
389 (license (list bsd-3
390 gpl2)))))
391
392(define-public hurd
393 (package
394 (name "hurd")
395 (source (origin
396 (inherit (package-source hurd-headers))
397 (patches (search-patches "hurd-pfinet-recv-control-block.patch"
398 "hurd-refcounts-assert.patch"
399 "hurd-rumpdisk-no-hd.patch"))))
400 (version (package-version hurd-headers))
401 (arguments
402 `(#:tests? #f ;no "check" target
403 #:phases
404 (modify-phases %standard-phases
405 (add-after 'unpack 'prepare-addons
406 (lambda* (#:key native-inputs inputs #:allow-other-keys)
407 ;; First we import the things we want from dde.
408 (for-each make-file-writable (find-files "."))
409 (let ((dde (assoc-ref (or native-inputs inputs) "dde-sources")))
410 (for-each (lambda (dir)
411 (copy-recursively
412 (string-append dde "/" dir ) dir))
413 '("libmachdevdde" "libddekit" "libdde_linux26")))
414 ;; And we add some as subdirs so that they're built by the main
415 ;; Makefile. libdde_linux26 is built later in its own phase.
416 (substitute* "Makefile"
417 (("libbpf ")
418 "libbpf libmachdevdde libddekit "))))
419 (add-before 'build 'pre-build
420 (lambda _
421 ;; Don't change the ownership of any file at this time.
422 (substitute* '("daemons/Makefile" "utils/Makefile")
423 (("-o root -m 4755") ""))
424 #t))
425 (add-after 'unpack 'create-runsystem
426 (lambda _
427 ;; XXX Work towards having startup.c invoke the Guile rc
428 (delete-file "daemons/runsystem.sh")
429 (with-output-to-file "daemons/runsystem.sh"
430 (lambda _
431 (display "#! /bin/bash
432
433# XXX Guile needs pipe support for its finalizer thread, to start.
434# Remove this script when Linux and the Hurd have xattr patches.
435PATH=@PATH@
436
437# XXX Work around a race condition (probably in the root translator).
438for i in $(seq 100000); do :; done
439
440# This is necessary to make stat / return the correct device ids.
441# As / should be read-only at this point, this should be a no-op.
442fsysopts / --update --readonly
443
444if test -f /etc/fstab; then
445 fsck --all --preen --verbose
446else
447 echo \"No /etc/fstab found, ignoring...\"
448fi
449
450case $? in
451# Successful completion
4520)
453 fsysopts / --writable
454 ;;
455# Filesystem modified (but ok now)
4561)
457 fsysopts / --writable
458 ;;
459# Filesystem modified, filesystem should be restarted
460# Ideally we would only restart the filesystem
4612 | 3)
462 # Note: this /sbin gets substituted
463 /sbin/reboot
464 ;;
465# Fsck couldn't fix it.
4664 | 5 | 8 | 9)
467 echo \"Automatic boot failed... help!\"
468 exit 1
469 ;;
470# Signal that really interrupted something
47120 | 130 | 131)
472 echo \"Boot interrupted\"
473 exit 1
474 ;;
475# Special `let fsck finish' interruption (SIGQUIT)
47612)
477 echo \"Boot interrupted (filesystem checks complete)\"
478 exit 1
479 ;;
480# Oh dear.
481*)
482 echo \"Unknown error during fsck (exit status $?)\"
483 exit 1
484 ;;
485esac
486
487# Create seed file to avoid
488# /gnu/store/...-hurd-x.y.z/hurd/random: Warning: Failed to read random seed file /var/lib/random-seed: No such file or directory
489mkdir -p /var/lib
490seq 1000 > /var/lib/random-seed
491
492# The random translators, especially /dev/urandom, need to be non-passive
493# When they exist in the file-system and reference /var/lib/random-seed
494# while / is read-only. console-run will hang.
495settrans --create --active /dev/random /hurd/random --seed-file /var/lib/random-seed
496settrans --create --active /dev/urandom /hurd/random --seed-file /var/lib/random-seed --fast
497
498# Only after this we can run guile.
499mkdir -p /servers/socket
500rm -f /servers/socket/1
501# Note: this /hurd gets substituted
502settrans --create /servers/socket/1 /hurd/pflocal
503
504# parse multiboot arguments
505for i in \"$@\"; do
506 case $i in
507 (gnu.system=*)
508 system=${i#gnu.system=}
509 ;;
510 esac
511done
512
513echo Starting ${system}/rc...
514exec ${system}/rc \"$@\"
515")))))
516 (add-before 'build 'set-file-names
517 (lambda* (#:key inputs outputs #:allow-other-keys)
518 (let* ((out (assoc-ref outputs "out"))
519 (bash (assoc-ref inputs "bash-minimal"))
520 (coreutils (assoc-ref inputs "coreutils"))
521 (sed (assoc-ref inputs "sed"))
522 (grep (assoc-ref inputs "grep"))
523 (util-linux (assoc-ref inputs "util-linux"))
524 (e2fsprogs (assoc-ref inputs "e2fsprogs")))
525 (substitute* '("daemons/runttys.c" "daemons/getty.c" "utils/login.c")
526 (("/bin/login")
527 (string-append out "/bin/login"))
528 (("/bin/bash") (string-append bash "/bin/bash")))
529 (substitute* '("startup/startup.c" "config/ttys")
530 (("/libexec/")
531 (string-append out "/libexec/")))
532 (substitute* '("utils/uptime.sh")
533 (("/bin/w")
534 (string-append out "/bin/w")))
535 ;; Upon first boot the /hurd symlink does not exist; it is
536 ;; created during activation: Hard-code the .../hurd store file
537 ;; name.
538 (substitute* '("boot/boot.c"
539 "daemons/console-run.c"
540 "startup/startup.c"
541 "sutils/swapon.c"
542 "tmpfs/tmpfs.c")
543 (("/hurd/")
544 (string-append out "/hurd/"))
545 (("/sbin/")
546 (string-append out "/sbin/")))
547 (substitute* '("libdiskfs/boot-start.c"
548 "libdiskfs/opts-std-startup.c")
549 (("_HURD_STARTUP")
550 (string-append "\"" out "/hurd/startup\"")))
551 (substitute* '("daemons/runsystem.sh"
552 "utils/fakeroot.sh"
553 "utils/remap.sh"
554 "sutils/MAKEDEV.sh"
555 "sutils/losetup.sh")
556 (("^PATH=.*")
557 (string-append "PATH=" out "/bin"
558 ":" out "/sbin"
559 ":" coreutils "/bin"
560 ":" e2fsprogs "/sbin"
561 ":" grep "/bin"
562 ":" sed "/bin"
563 ":" util-linux "/sbin\n"))
564 (("/sbin/") (string-append out "/sbin/"))
565 (("/libexec/") (string-append out "/libexec/"))
566 (("/hurd/") (string-append out "/hurd/")))
567 (substitute* "sutils/fsck.c"
568 (("/sbin/") (in-vicinity e2fsprogs "sbin/")))
569 (substitute* '("utils/remap.sh"
570 "utils/fakeroot.sh")
571 (("/bin/settrans") (string-append out "/bin/settrans"))
572 (("/bin/fakeauth") (string-append out "/bin/fakeauth"))))))
573 (add-after 'patch-shebangs 'patch-libexec-shebangs
574 (lambda* (#:key inputs outputs #:allow-other-keys)
575 ;; XXX: Since the 'patch-shebangs' phase doesn't traverse
576 ;; /libexec, do it here.
577 (let* ((out (assoc-ref outputs "out"))
578 (bash (assoc-ref inputs "bash-minimal"))
579 (path (list (string-append bash "/bin"))))
580 (for-each (lambda (file)
581 (patch-shebang file path))
582 (find-files (string-append out "/libexec"))))))
583 (add-after 'build 'build-libdde-linux
584 (lambda* (#:key inputs native-inputs #:allow-other-keys)
585 (let ((arch ,(match (or (%current-target-system)
586 (%current-system))
587 ((? target-x86-32?)
588 "x86")
589 ((? target-x86-64?)
590 "amd64")
591 (_
592 ;; XXX: Cross-compiling this package to an
593 ;; unsupported system.
594 "UNSUPPORTED_SYSTEM"))))
595 (when ,(target-hurd64?)
596 (let ((dir "libdde_linux26/build/include"))
597 (mkdir-p (string-append dir "/x86"))
598 (format #t "symlink ~a -> ~a\n"
599 (string-append dir "/x86/amd64") "x86")
600 (symlink "x86" (string-append dir "/amd64"))
601 (format #t "symlink ~a -> ~a\n"
602 (string-append dir "/amd64/asm-x86_64") "asm-x86")
603 (symlink "asm-x86" (string-append dir "/amd64/asm-x86_64"))))
604 (invoke (string-append (assoc-ref (or native-inputs inputs) "make")
605 "/bin/make")
606 ;; XXX There can be a race condition because subdirs
607 ;; aren't interdependent targets in the Makefile.
608 "-j1" "-C" "libdde_linux26"
609 (string-append "SHELL="
610 (assoc-ref (or native-inputs inputs) "bash")
611 "/bin/bash")
612 (string-append "CC="
613 ,(cc-for-target))
614 (string-append
615 "WARNINGS="
616 " -Wno-error=declaration-missing-parameter-type"
617 " -Wno-error=implicit-function-declaration"
618 " -Wno-error=implicit-int"
619 " -Wno-error=int-conversion"
620 " -Wno-error=strict-prototypes")
621 (string-append "ARCH=" arch)))))
622 (add-after 'install 'install-goodies
623 (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
624 ;; Install additional goodies.
625 ;; TODO: Build & install *.msgids for rpctrace.
626 (let* ((out (assoc-ref outputs "out"))
627 (datadir (string-append out "/share/hurd"))
628 (arch ,(match (or (%current-target-system)
629 (%current-system))
630 ((? target-x86-32?)
631 "x86")
632 ((? target-x86-64?)
633 "amd64")
634 (_
635 ;; XXX: Cross-compiling this package to an
636 ;; unsupported system.
637 "UNSUPPORTED_SYSTEM")))
638 (dir (string-append out "/share/libdde_linux26/build/include")))
639 (mkdir-p dir)
640 (when ,(target-hurd64?)
641 (mkdir-p (string-append dir "/amd64"))
642 (format #t "symlink ~a -> ~a\n"
643 (string-append dir "/amd64/asm-x86_64")
644 "x86")
645 (symlink "x86" (string-append dir "/amd46")))
646 (invoke (string-append (assoc-ref (or native-inputs inputs) "make")
647 "/bin/make")
648 "-C" "libdde_linux26" "install"
649 (string-append "SHELL="
650 (assoc-ref (or native-inputs inputs) "bash")
651 "/bin/bash")
652 (string-append "INSTALLDIR=" dir)
653 (string-append "ARCH=" arch))
654 (when ,(target-hurd64?)
655 (format #t "symlink ~a -> ~a\n"
656 (string-append dir "/amd64/asm-x86_64")
657 "asm-x86")
658 (symlink "asm-x86" (string-append dir "/amd64/asm-x86_64")))
659 ;; Install the fancy UTF-8 motd.
660 (mkdir-p (string-append out "/etc"))
661 (copy-file "console/motd.UTF8"
662 (string-append out "/etc/motd"))
663
664 ;; Install the BDF font for use by the console client.
665 (copy-file (assoc-ref inputs "unifont")
666 "unifont.gz")
667 (invoke "gunzip" "unifont.gz")
668 (mkdir-p datadir)
669 (copy-file "unifont"
670 (string-append datadir "/vga-system.bdf"))))))
671 #:configure-flags
672 ,#~(list (string-append "LDFLAGS=-Wl,-rpath="
673 #$output "/lib"
674 ;; Linking with librump.so
675 " -Wl,--as-needed")
676 "--enable-static-progs=ext2fs,iso9660fs,rumpdisk,pci-arbiter,acpi"
677 "--disable-ncursesw"
678 "--without-libbz2"
679 "--without-libz")))
680 (build-system gnu-build-system)
681 (inputs
682 `(("libacpica" ,libacpica) ;for hurd/acpi.static
683 ("libgcrypt" ,libgcrypt) ;for /hurd/random
684 ("libdaemon" ,libdaemon) ;for /bin/console --daemonize
685 ("libxcrypt" ,libxcrypt) ;for password hashing
686 ("unifont" ,unifont)
687 ("libpciaccess" ,libpciaccess-static)
688
689 ;; For NFS support
690 ("libtirpc" ,libtirpc)
691
692 ;; Tools for the /libexec/* scripts.
693 ("bash-minimal" ,bash-minimal)
694 ("coreutils" ,coreutils)
695 ("e2fsprogs" ,e2fsprogs) ;for fsck.ext2
696 ("sed" ,sed)
697 ("grep" ,grep)
698 ("util-linux" ,util-linux "static") ;libuuid.a, for parted
699 ("parted" ,parted) ;for rumpdisk
700 ("rumpkernel" ,rumpkernel)))
701 (native-inputs
702 `(("autoconf" ,autoconf)
703 ("automake" ,automake)
704 ("libgcrypt" ,libgcrypt) ;for 'libgcrypt-config'
705 ("mig" , (if (%current-target-system)
706 (cross-mig (%current-target-system))
707 mig))
708 ("pkg-config" ,pkg-config)
709 ("perl" ,perl)
710 ("texinfo" ,texinfo)
711 ("dde-sources" ,dde-sources)))
712 (supported-systems %hurd-systems)
713 (home-page "https://www.gnu.org/software/hurd/hurd.html")
714 (synopsis "The kernel servers for the GNU operating system")
715 (description
716 "The Hurd is the kernel for the GNU system, a replacement and
717augmentation of standard Unix kernels. It is a collection of protocols for
718system interaction (file systems, networks, authentication), and servers
719implementing them.")
720 (license gpl2+)))
721
722(define-public netdde
723 (let ((commit "c0ef248dc7c5ccc1273e2a796f3ece30c5b645df")
724 (revision "3"))
725 (package
726 (name "netdde")
727 ;; The version prefix corresponds to the version of Linux from which the
728 ;; drivers were taken.
729 (version (git-version "2.6.32.65" revision commit))
730 (source (origin
731 (method git-fetch)
732 (uri (git-reference
733 (url "https://git.savannah.gnu.org/git/hurd/incubator.git")
734 (commit commit)))
735 (patches (search-patches "netdde-build-fix.patch"
736 "netdde-csum.patch"))
737 (sha256
738 (base32
739 "070fpmd4nvn3mp8dj9w4if63iwz7j2m0h6ywq888znw70wlrc6sh"))
740 (file-name (git-file-name name commit))))
741 (build-system gnu-build-system)
742 (arguments
743 `(#:tests? #f ;no "check" target
744 #:make-flags
745 (list (string-append "SHELL="
746 (search-input-file %build-inputs "/bin/bash"))
747 "PKGDIR=libdde_linux26"
748 (string-append "CC=" ,(cc-for-target))
749 (string-append "WARNINGS="
750 " -Wno-error=declaration-missing-parameter-type"
751 " -Wno-error=implicit-function-declaration"
752 " -Wno-error=implicit-int"
753 " -Wno-error=int-conversion"
754 " -Wno-error=strict-prototypes")
755 (let ((arch ,(match (or (%current-target-system)
756 (%current-system))
757 ((? target-x86-32?)
758 "x86")
759 ((? target-x86-64?)
760 "amd64")
761 (_
762 ;; XXX: Cross-compiling this package to an
763 ;; unsupported system.
764 "UNSUPPORTED_SYSTEM"))))
765 (string-append "ARCH=" arch)))
766 #:configure-flags
767 ,#~(list (string-append "LDFLAGS=-Wl,-rpath=" #$output "/lib"))
768 #:phases
769 (modify-phases %standard-phases
770 (delete 'configure)
771 (add-after 'unpack 'prepare-dde
772 (lambda* (#:key native-inputs inputs #:allow-other-keys)
773 (for-each make-file-writable (find-files "."))
774 (let ((dde (assoc-ref (or native-inputs inputs) "dde-sources")))
775 (for-each (lambda (dir)
776 (copy-recursively
777 (string-append dde "/" dir ) dir))
778 '("libdde_linux26" "libddekit")))
779 (substitute* "libdde_linux26/mk/rel2abs.sh"
780 (("/bin/bash") (which "bash")))))
781 (add-after 'patch-generated-file-shebangs 'build-libdde-linux26
782 (lambda* (#:key make-flags #:allow-other-keys)
783 (when ,(target-hurd64?)
784 (let ((dir "libdde_linux26/build/include"))
785 (mkdir-p (string-append dir "/x86"))
786 (format #t "symlink ~a -> ~a\n"
787 (string-append dir "/x86/amd64") "x86")
788 (symlink "x86" (string-append dir "/amd64"))
789 (format #t "symlink ~a -> ~a\n"
790 (string-append dir "/amd64/asm-x86_64") "asm-x86")
791 (symlink "asm-x86" (string-append dir "/amd64/asm-x86_64"))))
792 (with-directory-excursion "libdde_linux26"
793 (apply invoke "make"
794 (delete "PKGDIR=libdde_linux26" make-flags)))))
795 (add-after 'build-libdde-linux26 'convert
796 (lambda* (#:key make-flags #:allow-other-keys)
797 (apply invoke "make" "convert" make-flags)))
798 (replace 'build
799 (lambda* (#:key make-flags #:allow-other-keys)
800 (apply invoke "make"
801 ,(string-append "LINK_PROGRAM=" (cc-for-target))
802 make-flags)
803 ;; This hack to build netdde.static was found in
804 ;; https://salsa.debian.org/hurd-team/netdde/-/blob/b539b2ad7a171371f140c3da58cce33f1a91ac12/debian/rules
805 (delete-file "Makefile.inc")
806 (apply invoke "make"
807 ,(string-append "LINK_PROGRAM=" (cc-for-target) " -static")
808 "TARGET=netdde.static"
809 make-flags)))
810 (replace 'install
811 (lambda* (#:key outputs #:allow-other-keys)
812 (let ((hurd (string-append (assoc-ref outputs "out") "/hurd")))
813 (install-file "netdde" hurd)
814 (install-file "netdde.static" hurd)))))))
815 (inputs
816 (list hurd libpciaccess-static zlib `(,zlib "static")))
817 (native-inputs
818 `(("coreutils" ,coreutils)
819 ("gawk" ,gawk)
820 ("grep" ,grep)
821 ("perl" ,perl)
822 ("sed" ,sed)
823 ("dde-sources" ,dde-sources)))
824 (supported-systems %hurd-systems)
825 (home-page "https://www.gnu.org/software/hurd/hurd.html")
826 (synopsis "Linux network drivers glued by the DDE layer")
827 (description
828 "This package provides Linux 2.6 network drivers that can be embedded
829in userland processes thanks to the DDE layer.")
830 ;; Some drivers are dually licensed with the options being GPLv2 or one
831 ;; of MPL/Expat/BSD-3 (dependent on the driver).
832 (license gpl2))))
833
834(define-public rumpkernel
835 (let ((commit "debian/0_20250111-6")
836 (revision "1"))
837 (package
838 (name "rumpkernel")
839 (version (git-version "0-20250111" revision (substring commit 7)))
840 ;; This uses the Debian Salsa rumpkernel package git as upstream as that
841 ;; is where development happens. Once things have stabilized, upstream
842 ;; may change to the NetBSD git from where Debian takes their snapshots.
843 (source (origin
844 (method git-fetch)
845 (uri (git-reference
846 (url "https://salsa.debian.org/hurd-team/rumpkernel.git")
847 (commit commit)))
848 (sha256
849 (base32
850 "1pvd54k06rlgvppfbzl1d0qqcjc0kshamw1iw40s3apabh87pw1i"))
851 (file-name (git-file-name name version))))
852 (build-system gnu-build-system)
853 (arguments
854 (list
855 #:tests? #f
856 #:modules '((srfi srfi-26)
857 (ice-9 rdelim)
858 (guix build utils)
859 (guix build gnu-build-system))
860 ;; As we are using the Debian package as upstream, we follow their
861 ;; build:
862 ;; * apply patches in debian/patches taken from the
863 ;; debian/patches/series file
864 ;; * for the configure, make, and install stages, follow
865 ;; the code in debian/rules
866 ;; The Debian patchset includes a cross build feature that we
867 ;; use with two differences
868 ;; * Debian uses a multiarch toolchain
869 ;; * we use cross-mig
870 #:phases
871 #~(modify-phases %standard-phases
872 (add-after 'unpack 'apply-patches
873 (lambda* (#:key target #:allow-other-keys)
874 (let* ((patch-directory "debian/patches/")
875 (series (string-append patch-directory "series"))
876 (text (with-input-from-file series read-string))
877 (lines (string-split (string-trim-right text) #\newline))
878 (patches (filter (negate (cute string-prefix? "#" <>))
879 lines))
880 (patch-files (map
881 (cute string-append patch-directory <>)
882 patches)))
883 (for-each
884 (cute invoke "patch" "--force" "-p1" "-i" <>)
885 patch-files)
886 ;; Somewhere in the build.sh/make process MIG is not being
887 ;; exported, apparently.
888 (let* ((prefix (if (not target) "" (string-append target "-")))
889 (mig (string-append prefix "mig")))
890 (substitute* "pci-userspace/src-gnu/Makefile.inc"
891 (("MIG=mig")
892 (string-append "MIG=" mig)))))))
893 (add-before 'configure 'setenv
894 (lambda* (#:key build target #:allow-other-keys)
895 (define (noisy-setenv name value)
896 (setenv name value)
897 (format (current-error-port) "set ~a=~s\n" name value))
898 (noisy-setenv "HOST_CC" "gcc")
899 (let* ((prefix (if (not target) "" (string-append target "-"))))
900 (noisy-setenv "TARGET_AR" (string-append prefix "ar"))
901 (noisy-setenv "TARGET_CC" (string-append prefix "gcc"))
902 (noisy-setenv "TARGET_CXX" (string-append prefix "g++"))
903 (noisy-setenv "TARGET_LD" (string-append prefix "ld"))
904 (noisy-setenv "TARGET_MIG" (string-append prefix "mig"))
905 (noisy-setenv "TARGET_NM" (string-append prefix "nm"))
906 (noisy-setenv "MIG" (string-append prefix "mig")))
907 (setenv "PAWD" "pwd")
908 (for-each
909 (cute noisy-setenv <> "")
910 '("_GCC_CRTENDS"
911 "_GCC_CRTEND"
912 "_GCC_CRTBEGINS"
913 "_GCC_CRTBEGIN"
914 "_GCC_CRTI"
915 "_GCC_CRTN"))))
916 (replace 'configure
917 (lambda args
918 (let ((configure (assoc-ref %standard-phases 'configure)))
919 (with-directory-excursion "buildrump.sh/src/lib/librumpuser"
920 (apply configure args)))))
921 ;; The build has three toplevel entry points
922 ;; * buildrump.sh/src/build.sh: create a NetBSD-compatible
923 ;; toolchain and supports cross-compiling
924 ;; * buildrump.sh/src/lib/librumpuser: the librump* libraries
925 ;; * pci-userspace/src-gnu: the librumpdev_pci* libraries
926 (replace 'build
927 (lambda* (#:key parallel-build? #:allow-other-keys)
928 (let* ((jobs (if parallel-build? (parallel-job-count) 1))
929 (host-cpu #$(match (or (%current-target-system)
930 (%current-system))
931 ((? target-x86-32?)
932 "i386")
933 ((? target-x86-64?)
934 "amd64")
935 (_ "unknown")))
936 (toprump (string-append
937 (getcwd)
938 "/buildrump.sh/src/sys/rump"))
939 (rump-make (string-append
940 (getcwd)
941 "/buildrump.sh/src/obj/tooldir/bin/nbmake-"
942 host-cpu)))
943 (mkdir "obj")
944 (with-directory-excursion "buildrump.sh/src"
945 (invoke
946 "sh" "build.sh"
947 "-V" "TOOLS_BUILDRUMP=yes"
948 "-V" "MKBINUTILS=no"
949 "-V" "MKGDB=no"
950 "-V" "MKGROFF=no"
951 "-V" "MKDTRACE=no"
952 "-V" "MKZFS=no"
953
954 "-V" (string-append "TOPRUMP=" toprump)
955 "-V" "BUILDRUMP_CPPFLAGS=-Wno-error=stringop-overread"
956 "-V" "RUMPUSER_EXTERNAL_DPLIBS=pthread"
957 ;; build.sh unsets C_INCLUDE_PATH which breaks our HOST_CC
958 "-V" (string-append "C_INCLUDE_PATH=" (getenv "C_INCLUDE_PATH"))
959 "-V" (string-append
960 "CPPFLAGS="
961 " -I../../obj/destdir." host-cpu "/usr/include"
962 " -D_FILE_OFFSET_BITS=64"
963 " -DRUMP_REGISTER_T=int"
964 " -DRUMPUSER_CONFIG=yes"
965 " -DNO_PCI_MSI_MSIX=yes"
966 " -DNUSB_DMA=1"
967 " -DPAE"
968 " -DBUFPAGES=16")
969 "-V" (string-append
970 "CWARNFLAGS="
971 " -Wno-error=maybe-uninitialized"
972 " -Wno-error=address-of-packed-member"
973 " -Wno-error=unused-variable"
974 " -Wno-error=stack-protector"
975 " -Wno-error=array-parameter"
976 " -Wno-error=array-bounds"
977 " -Wno-error=stringop-overflow"
978 " -Wno-error=sign-compare")
979 "-V" "LIBCRTBEGIN="
980 "-V" "LIBCRTEND="
981 "-V" "LIBCRT0="
982 "-V" "LIBCRTI="
983 "-V" "_GCC_CRTENDS="
984 "-V" "_GCC_CRTEND="
985 "-V" "_GCC_CRTBEGINS="
986 "-V" "_GCC_CRTBEGIN="
987 "-V" "_GCC_CRTI="
988 "-V" "_GCC_CRTN="
989 "-U"
990 "-u"
991 "-T" "./obj/tooldir"
992 "-m" host-cpu
993 "-j" (number->string jobs)
994 "tools"
995 "rump"))
996 (with-directory-excursion "buildrump.sh/src/lib/librumpuser"
997 (setenv "RUMPRUN" "true")
998 (invoke rump-make "dependall"))
999 (with-directory-excursion "pci-userspace/src-gnu"
1000 (invoke rump-make "dependall")))))
1001 (replace 'install
1002 (lambda _
1003 (define (install-file file target)
1004 (let ((dest (string-append target (basename file))))
1005 (format (current-output-port) "`~a' -> `~a'~%" file dest)
1006 (mkdir-p (dirname dest))
1007 ;; Some libraries are duplicated/copied around in the
1008 ;; build system, do not fail trying to install one
1009 ;; a second time.
1010 (if (file-exists? dest)
1011 (format (current-error-port)
1012 "warning: skipping: ~a\n" file)
1013 (let ((stat (lstat file)))
1014 (case (stat:type stat)
1015 ((symlink)
1016 (let ((target (readlink file)))
1017 (symlink target dest)))
1018 (else
1019 (copy-file file dest)))))))
1020 (let ((header (string-append #$output "/include/rump"))
1021 (lib (string-append #$output "/lib/")))
1022 (mkdir-p header)
1023 (copy-recursively "buildrump.sh/src/sys/rump/include/rump"
1024 header)
1025 (mkdir-p lib)
1026 (for-each
1027 (cute install-file <> lib)
1028 (append (find-files "buildrump.sh/src" "librump.*[.](a|so.*)")
1029 (find-files "obj" "librump.*[.](a|so.*)")))))))))
1030 (inputs
1031 (list gnumach-headers libpciaccess libirqhelp))
1032 (native-inputs
1033 (list autoconf
1034 automake
1035 libgcrypt
1036 (if (%current-target-system)
1037 (cross-mig (%current-target-system))
1038 mig)
1039 zlib))
1040 (supported-systems %hurd-systems)
1041 (home-page "https://wiki.netbsd.org/rumpkernel")
1042 (synopsis "NetBSD as rumpkernel for the GNU/Hurd")
1043 (description
1044 "This package provides NetBSD as rumpkernel for the GNU/Hurd, so that
1045the Hurd may be installed on iron. Using this rumpkernel package, the hurd
1046package's rumpdisk can be built which provides the pci.arbiter and rumpdisk
1047servers.")
1048 (license
1049 ;; The NetBSD rumpkernel code is a big hodgepodge of softwares many of
1050 ;; which have their own different licensing terms, see also
1051 ;; https://salsa.debian.org/hurd-team/rumpkernel/-/blob/master/debian/copyright
1052 (list asl2.0
1053 boost1.0
1054 bsd-2
1055 bsd-3
1056 bsd-4
1057 cddl1.0
1058 expat
1059 gpl1
1060 gpl2+
1061 gpl3+
1062 isc
1063 lgpl2.0+
1064 public-domain
1065 (@ (guix licenses) zlib)
1066 (non-copyleft "file://src/lib/libc/hash/hashhl.c"
1067 "See debian/copyright in the distribution."))))))