projects/guix·blob javascript-team · refs

1069 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
437umask 022
438
439# XXX Work around a race condition (probably in the root translator).
440for i in $(seq 100000); do :; done
441
442# This is necessary to make stat / return the correct device ids.
443# As / should be read-only at this point, this should be a no-op.
444fsysopts / --update --readonly
445
446if test -f /etc/fstab; then
447 fsck --all --preen --verbose
448else
449 echo \"No /etc/fstab found, ignoring...\"
450fi
451
452case $? in
453# Successful completion
4540)
455 fsysopts / --writable
456 ;;
457# Filesystem modified (but ok now)
4581)
459 fsysopts / --writable
460 ;;
461# Filesystem modified, filesystem should be restarted
462# Ideally we would only restart the filesystem
4632 | 3)
464 # Note: this /sbin gets substituted
465 /sbin/reboot
466 ;;
467# Fsck couldn't fix it.
4684 | 5 | 8 | 9)
469 echo \"Automatic boot failed... help!\"
470 exit 1
471 ;;
472# Signal that really interrupted something
47320 | 130 | 131)
474 echo \"Boot interrupted\"
475 exit 1
476 ;;
477# Special `let fsck finish' interruption (SIGQUIT)
47812)
479 echo \"Boot interrupted (filesystem checks complete)\"
480 exit 1
481 ;;
482# Oh dear.
483*)
484 echo \"Unknown error during fsck (exit status $?)\"
485 exit 1
486 ;;
487esac
488
489# Create seed file to avoid
490# /gnu/store/...-hurd-x.y.z/hurd/random: Warning: Failed to read random seed file /var/lib/random-seed: No such file or directory
491mkdir -p /var/lib
492seq 1000 > /var/lib/random-seed
493
494# The random translators, especially /dev/urandom, need to be non-passive
495# When they exist in the file-system and reference /var/lib/random-seed
496# while / is read-only. console-run will hang.
497settrans --create --active /dev/random /hurd/random --seed-file /var/lib/random-seed
498settrans --create --active /dev/urandom /hurd/random --seed-file /var/lib/random-seed --fast
499
500# Only after this we can run guile.
501mkdir -p /servers/socket
502rm -f /servers/socket/1
503# Note: this /hurd gets substituted
504settrans --create /servers/socket/1 /hurd/pflocal
505
506# parse multiboot arguments
507for i in \"$@\"; do
508 case $i in
509 (gnu.system=*)
510 system=${i#gnu.system=}
511 ;;
512 esac
513done
514
515echo Starting ${system}/rc...
516exec ${system}/rc \"$@\"
517")))))
518 (add-before 'build 'set-file-names
519 (lambda* (#:key inputs outputs #:allow-other-keys)
520 (let* ((out (assoc-ref outputs "out"))
521 (bash (assoc-ref inputs "bash-minimal"))
522 (coreutils (assoc-ref inputs "coreutils"))
523 (sed (assoc-ref inputs "sed"))
524 (grep (assoc-ref inputs "grep"))
525 (util-linux (assoc-ref inputs "util-linux"))
526 (e2fsprogs (assoc-ref inputs "e2fsprogs")))
527 (substitute* '("daemons/runttys.c" "daemons/getty.c" "utils/login.c")
528 (("/bin/login")
529 (string-append out "/bin/login"))
530 (("/bin/bash") (string-append bash "/bin/bash")))
531 (substitute* '("startup/startup.c" "config/ttys")
532 (("/libexec/")
533 (string-append out "/libexec/")))
534 (substitute* '("utils/uptime.sh")
535 (("/bin/w")
536 (string-append out "/bin/w")))
537 ;; Upon first boot the /hurd symlink does not exist; it is
538 ;; created during activation: Hard-code the .../hurd store file
539 ;; name.
540 (substitute* '("boot/boot.c"
541 "daemons/console-run.c"
542 "startup/startup.c"
543 "sutils/swapon.c"
544 "tmpfs/tmpfs.c")
545 (("/hurd/")
546 (string-append out "/hurd/"))
547 (("/sbin/")
548 (string-append out "/sbin/")))
549 (substitute* '("libdiskfs/boot-start.c"
550 "libdiskfs/opts-std-startup.c")
551 (("_HURD_STARTUP")
552 (string-append "\"" out "/hurd/startup\"")))
553 (substitute* '("daemons/runsystem.sh"
554 "utils/fakeroot.sh"
555 "utils/remap.sh"
556 "sutils/MAKEDEV.sh"
557 "sutils/losetup.sh")
558 (("^PATH=.*")
559 (string-append "PATH=" out "/bin"
560 ":" out "/sbin"
561 ":" coreutils "/bin"
562 ":" e2fsprogs "/sbin"
563 ":" grep "/bin"
564 ":" sed "/bin"
565 ":" util-linux "/sbin\n"))
566 (("/sbin/") (string-append out "/sbin/"))
567 (("/libexec/") (string-append out "/libexec/"))
568 (("/hurd/") (string-append out "/hurd/")))
569 (substitute* "sutils/fsck.c"
570 (("/sbin/") (in-vicinity e2fsprogs "sbin/")))
571 (substitute* '("utils/remap.sh"
572 "utils/fakeroot.sh")
573 (("/bin/settrans") (string-append out "/bin/settrans"))
574 (("/bin/fakeauth") (string-append out "/bin/fakeauth"))))))
575 (add-after 'patch-shebangs 'patch-libexec-shebangs
576 (lambda* (#:key inputs outputs #:allow-other-keys)
577 ;; XXX: Since the 'patch-shebangs' phase doesn't traverse
578 ;; /libexec, do it here.
579 (let* ((out (assoc-ref outputs "out"))
580 (bash (assoc-ref inputs "bash-minimal"))
581 (path (list (string-append bash "/bin"))))
582 (for-each (lambda (file)
583 (patch-shebang file path))
584 (find-files (string-append out "/libexec"))))))
585 (add-after 'build 'build-libdde-linux
586 (lambda* (#:key inputs native-inputs #:allow-other-keys)
587 (let ((arch ,(match (or (%current-target-system)
588 (%current-system))
589 ((? target-x86-32?)
590 "x86")
591 ((? target-x86-64?)
592 "amd64")
593 (_
594 ;; XXX: Cross-compiling this package to an
595 ;; unsupported system.
596 "UNSUPPORTED_SYSTEM"))))
597 (when ,(target-hurd64?)
598 (let ((dir "libdde_linux26/build/include"))
599 (mkdir-p (string-append dir "/x86"))
600 (format #t "symlink ~a -> ~a\n"
601 (string-append dir "/x86/amd64") "x86")
602 (symlink "x86" (string-append dir "/amd64"))
603 (format #t "symlink ~a -> ~a\n"
604 (string-append dir "/amd64/asm-x86_64") "asm-x86")
605 (symlink "asm-x86" (string-append dir "/amd64/asm-x86_64"))))
606 (invoke (string-append (assoc-ref (or native-inputs inputs) "make")
607 "/bin/make")
608 ;; XXX There can be a race condition because subdirs
609 ;; aren't interdependent targets in the Makefile.
610 "-j1" "-C" "libdde_linux26"
611 (string-append "SHELL="
612 (assoc-ref (or native-inputs inputs) "bash")
613 "/bin/bash")
614 (string-append "CC="
615 ,(cc-for-target))
616 (string-append
617 "WARNINGS="
618 " -Wno-error=declaration-missing-parameter-type"
619 " -Wno-error=implicit-function-declaration"
620 " -Wno-error=implicit-int"
621 " -Wno-error=int-conversion"
622 " -Wno-error=strict-prototypes")
623 (string-append "ARCH=" arch)))))
624 (add-after 'install 'install-goodies
625 (lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
626 ;; Install additional goodies.
627 ;; TODO: Build & install *.msgids for rpctrace.
628 (let* ((out (assoc-ref outputs "out"))
629 (datadir (string-append out "/share/hurd"))
630 (arch ,(match (or (%current-target-system)
631 (%current-system))
632 ((? target-x86-32?)
633 "x86")
634 ((? target-x86-64?)
635 "amd64")
636 (_
637 ;; XXX: Cross-compiling this package to an
638 ;; unsupported system.
639 "UNSUPPORTED_SYSTEM")))
640 (dir (string-append out "/share/libdde_linux26/build/include")))
641 (mkdir-p dir)
642 (when ,(target-hurd64?)
643 (mkdir-p (string-append dir "/amd64"))
644 (format #t "symlink ~a -> ~a\n"
645 (string-append dir "/amd64/asm-x86_64")
646 "x86")
647 (symlink "x86" (string-append dir "/amd46")))
648 (invoke (string-append (assoc-ref (or native-inputs inputs) "make")
649 "/bin/make")
650 "-C" "libdde_linux26" "install"
651 (string-append "SHELL="
652 (assoc-ref (or native-inputs inputs) "bash")
653 "/bin/bash")
654 (string-append "INSTALLDIR=" dir)
655 (string-append "ARCH=" arch))
656 (when ,(target-hurd64?)
657 (format #t "symlink ~a -> ~a\n"
658 (string-append dir "/amd64/asm-x86_64")
659 "asm-x86")
660 (symlink "asm-x86" (string-append dir "/amd64/asm-x86_64")))
661 ;; Install the fancy UTF-8 motd.
662 (mkdir-p (string-append out "/etc"))
663 (copy-file "console/motd.UTF8"
664 (string-append out "/etc/motd"))
665
666 ;; Install the BDF font for use by the console client.
667 (copy-file (assoc-ref inputs "unifont")
668 "unifont.gz")
669 (invoke "gunzip" "unifont.gz")
670 (mkdir-p datadir)
671 (copy-file "unifont"
672 (string-append datadir "/vga-system.bdf"))))))
673 #:configure-flags
674 ,#~(list (string-append "LDFLAGS=-Wl,-rpath="
675 #$output "/lib"
676 ;; Linking with librump.so
677 " -Wl,--as-needed")
678 "--enable-static-progs=ext2fs,iso9660fs,rumpdisk,pci-arbiter,acpi"
679 "--disable-ncursesw"
680 "--without-libbz2"
681 "--without-libz")))
682 (build-system gnu-build-system)
683 (inputs
684 `(("libacpica" ,libacpica) ;for hurd/acpi.static
685 ("libgcrypt" ,libgcrypt) ;for /hurd/random
686 ("libdaemon" ,libdaemon) ;for /bin/console --daemonize
687 ("libxcrypt" ,libxcrypt) ;for password hashing
688 ("unifont" ,unifont)
689 ("libpciaccess" ,libpciaccess-static)
690
691 ;; For NFS support
692 ("libtirpc" ,libtirpc)
693
694 ;; Tools for the /libexec/* scripts.
695 ("bash-minimal" ,bash-minimal)
696 ("coreutils" ,coreutils)
697 ("e2fsprogs" ,e2fsprogs) ;for fsck.ext2
698 ("sed" ,sed)
699 ("grep" ,grep)
700 ("util-linux" ,util-linux "static") ;libuuid.a, for parted
701 ("parted" ,parted) ;for rumpdisk
702 ("rumpkernel" ,rumpkernel)))
703 (native-inputs
704 `(("autoconf" ,autoconf)
705 ("automake" ,automake)
706 ("libgcrypt" ,libgcrypt) ;for 'libgcrypt-config'
707 ("mig" , (if (%current-target-system)
708 (cross-mig (%current-target-system))
709 mig))
710 ("pkg-config" ,pkg-config)
711 ("perl" ,perl)
712 ("texinfo" ,texinfo)
713 ("dde-sources" ,dde-sources)))
714 (supported-systems %hurd-systems)
715 (home-page "https://www.gnu.org/software/hurd/hurd.html")
716 (synopsis "The kernel servers for the GNU operating system")
717 (description
718 "The Hurd is the kernel for the GNU system, a replacement and
719augmentation of standard Unix kernels. It is a collection of protocols for
720system interaction (file systems, networks, authentication), and servers
721implementing them.")
722 (license gpl2+)))
723
724(define-public netdde
725 (let ((commit "c0ef248dc7c5ccc1273e2a796f3ece30c5b645df")
726 (revision "3"))
727 (package
728 (name "netdde")
729 ;; The version prefix corresponds to the version of Linux from which the
730 ;; drivers were taken.
731 (version (git-version "2.6.32.65" revision commit))
732 (source (origin
733 (method git-fetch)
734 (uri (git-reference
735 (url "https://git.savannah.gnu.org/git/hurd/incubator.git")
736 (commit commit)))
737 (patches (search-patches "netdde-build-fix.patch"
738 "netdde-csum.patch"))
739 (sha256
740 (base32
741 "070fpmd4nvn3mp8dj9w4if63iwz7j2m0h6ywq888znw70wlrc6sh"))
742 (file-name (git-file-name name commit))))
743 (build-system gnu-build-system)
744 (arguments
745 `(#:tests? #f ;no "check" target
746 #:make-flags
747 (list (string-append "SHELL="
748 (search-input-file %build-inputs "/bin/bash"))
749 "PKGDIR=libdde_linux26"
750 (string-append "CC=" ,(cc-for-target))
751 (string-append "WARNINGS="
752 " -Wno-error=declaration-missing-parameter-type"
753 " -Wno-error=implicit-function-declaration"
754 " -Wno-error=implicit-int"
755 " -Wno-error=int-conversion"
756 " -Wno-error=strict-prototypes")
757 (let ((arch ,(match (or (%current-target-system)
758 (%current-system))
759 ((? target-x86-32?)
760 "x86")
761 ((? target-x86-64?)
762 "amd64")
763 (_
764 ;; XXX: Cross-compiling this package to an
765 ;; unsupported system.
766 "UNSUPPORTED_SYSTEM"))))
767 (string-append "ARCH=" arch)))
768 #:configure-flags
769 ,#~(list (string-append "LDFLAGS=-Wl,-rpath=" #$output "/lib"))
770 #:phases
771 (modify-phases %standard-phases
772 (delete 'configure)
773 (add-after 'unpack 'prepare-dde
774 (lambda* (#:key native-inputs inputs #:allow-other-keys)
775 (for-each make-file-writable (find-files "."))
776 (let ((dde (assoc-ref (or native-inputs inputs) "dde-sources")))
777 (for-each (lambda (dir)
778 (copy-recursively
779 (string-append dde "/" dir ) dir))
780 '("libdde_linux26" "libddekit")))
781 (substitute* "libdde_linux26/mk/rel2abs.sh"
782 (("/bin/bash") (which "bash")))))
783 (add-after 'patch-generated-file-shebangs 'build-libdde-linux26
784 (lambda* (#:key make-flags #:allow-other-keys)
785 (when ,(target-hurd64?)
786 (let ((dir "libdde_linux26/build/include"))
787 (mkdir-p (string-append dir "/x86"))
788 (format #t "symlink ~a -> ~a\n"
789 (string-append dir "/x86/amd64") "x86")
790 (symlink "x86" (string-append dir "/amd64"))
791 (format #t "symlink ~a -> ~a\n"
792 (string-append dir "/amd64/asm-x86_64") "asm-x86")
793 (symlink "asm-x86" (string-append dir "/amd64/asm-x86_64"))))
794 (with-directory-excursion "libdde_linux26"
795 (apply invoke "make"
796 (delete "PKGDIR=libdde_linux26" make-flags)))))
797 (add-after 'build-libdde-linux26 'convert
798 (lambda* (#:key make-flags #:allow-other-keys)
799 (apply invoke "make" "convert" make-flags)))
800 (replace 'build
801 (lambda* (#:key make-flags #:allow-other-keys)
802 (apply invoke "make"
803 ,(string-append "LINK_PROGRAM=" (cc-for-target))
804 make-flags)
805 ;; This hack to build netdde.static was found in
806 ;; https://salsa.debian.org/hurd-team/netdde/-/blob/b539b2ad7a171371f140c3da58cce33f1a91ac12/debian/rules
807 (delete-file "Makefile.inc")
808 (apply invoke "make"
809 ,(string-append "LINK_PROGRAM=" (cc-for-target) " -static")
810 "TARGET=netdde.static"
811 make-flags)))
812 (replace 'install
813 (lambda* (#:key outputs #:allow-other-keys)
814 (let ((hurd (string-append (assoc-ref outputs "out") "/hurd")))
815 (install-file "netdde" hurd)
816 (install-file "netdde.static" hurd)))))))
817 (inputs
818 (list hurd libpciaccess-static zlib `(,zlib "static")))
819 (native-inputs
820 `(("coreutils" ,coreutils)
821 ("gawk" ,gawk)
822 ("grep" ,grep)
823 ("perl" ,perl)
824 ("sed" ,sed)
825 ("dde-sources" ,dde-sources)))
826 (supported-systems %hurd-systems)
827 (home-page "https://www.gnu.org/software/hurd/hurd.html")
828 (synopsis "Linux network drivers glued by the DDE layer")
829 (description
830 "This package provides Linux 2.6 network drivers that can be embedded
831in userland processes thanks to the DDE layer.")
832 ;; Some drivers are dually licensed with the options being GPLv2 or one
833 ;; of MPL/Expat/BSD-3 (dependent on the driver).
834 (license gpl2))))
835
836(define-public rumpkernel
837 (let ((commit "debian/0_20250111-6")
838 (revision "1"))
839 (package
840 (name "rumpkernel")
841 (version (git-version "0-20250111" revision (substring commit 7)))
842 ;; This uses the Debian Salsa rumpkernel package git as upstream as that
843 ;; is where development happens. Once things have stabilized, upstream
844 ;; may change to the NetBSD git from where Debian takes their snapshots.
845 (source (origin
846 (method git-fetch)
847 (uri (git-reference
848 (url "https://salsa.debian.org/hurd-team/rumpkernel.git")
849 (commit commit)))
850 (sha256
851 (base32
852 "1pvd54k06rlgvppfbzl1d0qqcjc0kshamw1iw40s3apabh87pw1i"))
853 (file-name (git-file-name name version))))
854 (build-system gnu-build-system)
855 (arguments
856 (list
857 #:tests? #f
858 #:modules '((srfi srfi-26)
859 (ice-9 rdelim)
860 (guix build utils)
861 (guix build gnu-build-system))
862 ;; As we are using the Debian package as upstream, we follow their
863 ;; build:
864 ;; * apply patches in debian/patches taken from the
865 ;; debian/patches/series file
866 ;; * for the configure, make, and install stages, follow
867 ;; the code in debian/rules
868 ;; The Debian patchset includes a cross build feature that we
869 ;; use with two differences
870 ;; * Debian uses a multiarch toolchain
871 ;; * we use cross-mig
872 #:phases
873 #~(modify-phases %standard-phases
874 (add-after 'unpack 'apply-patches
875 (lambda* (#:key target #:allow-other-keys)
876 (let* ((patch-directory "debian/patches/")
877 (series (string-append patch-directory "series"))
878 (text (with-input-from-file series read-string))
879 (lines (string-split (string-trim-right text) #\newline))
880 (patches (filter (negate (cute string-prefix? "#" <>))
881 lines))
882 (patch-files (map
883 (cute string-append patch-directory <>)
884 patches)))
885 (for-each
886 (cute invoke "patch" "--force" "-p1" "-i" <>)
887 patch-files)
888 ;; Somewhere in the build.sh/make process MIG is not being
889 ;; exported, apparently.
890 (let* ((prefix (if (not target) "" (string-append target "-")))
891 (mig (string-append prefix "mig")))
892 (substitute* "pci-userspace/src-gnu/Makefile.inc"
893 (("MIG=mig")
894 (string-append "MIG=" mig)))))))
895 (add-before 'configure 'setenv
896 (lambda* (#:key build target #:allow-other-keys)
897 (define (noisy-setenv name value)
898 (setenv name value)
899 (format (current-error-port) "set ~a=~s\n" name value))
900 (noisy-setenv "HOST_CC" "gcc")
901 (let* ((prefix (if (not target) "" (string-append target "-"))))
902 (noisy-setenv "TARGET_AR" (string-append prefix "ar"))
903 (noisy-setenv "TARGET_CC" (string-append prefix "gcc"))
904 (noisy-setenv "TARGET_CXX" (string-append prefix "g++"))
905 (noisy-setenv "TARGET_LD" (string-append prefix "ld"))
906 (noisy-setenv "TARGET_MIG" (string-append prefix "mig"))
907 (noisy-setenv "TARGET_NM" (string-append prefix "nm"))
908 (noisy-setenv "MIG" (string-append prefix "mig")))
909 (setenv "PAWD" "pwd")
910 (for-each
911 (cute noisy-setenv <> "")
912 '("_GCC_CRTENDS"
913 "_GCC_CRTEND"
914 "_GCC_CRTBEGINS"
915 "_GCC_CRTBEGIN"
916 "_GCC_CRTI"
917 "_GCC_CRTN"))))
918 (replace 'configure
919 (lambda args
920 (let ((configure (assoc-ref %standard-phases 'configure)))
921 (with-directory-excursion "buildrump.sh/src/lib/librumpuser"
922 (apply configure args)))))
923 ;; The build has three toplevel entry points
924 ;; * buildrump.sh/src/build.sh: create a NetBSD-compatible
925 ;; toolchain and supports cross-compiling
926 ;; * buildrump.sh/src/lib/librumpuser: the librump* libraries
927 ;; * pci-userspace/src-gnu: the librumpdev_pci* libraries
928 (replace 'build
929 (lambda* (#:key parallel-build? #:allow-other-keys)
930 (let* ((jobs (if parallel-build? (parallel-job-count) 1))
931 (host-cpu #$(match (or (%current-target-system)
932 (%current-system))
933 ((? target-x86-32?)
934 "i386")
935 ((? target-x86-64?)
936 "amd64")
937 (_ "unknown")))
938 (toprump (string-append
939 (getcwd)
940 "/buildrump.sh/src/sys/rump"))
941 (rump-make (string-append
942 (getcwd)
943 "/buildrump.sh/src/obj/tooldir/bin/nbmake-"
944 host-cpu)))
945 (mkdir "obj")
946 (with-directory-excursion "buildrump.sh/src"
947 (invoke
948 "sh" "build.sh"
949 "-V" "TOOLS_BUILDRUMP=yes"
950 "-V" "MKBINUTILS=no"
951 "-V" "MKGDB=no"
952 "-V" "MKGROFF=no"
953 "-V" "MKDTRACE=no"
954 "-V" "MKZFS=no"
955
956 "-V" (string-append "TOPRUMP=" toprump)
957 "-V" "BUILDRUMP_CPPFLAGS=-Wno-error=stringop-overread"
958 "-V" "RUMPUSER_EXTERNAL_DPLIBS=pthread"
959 ;; build.sh unsets C_INCLUDE_PATH which breaks our HOST_CC
960 "-V" (string-append "C_INCLUDE_PATH=" (getenv "C_INCLUDE_PATH"))
961 "-V" (string-append
962 "CPPFLAGS="
963 " -I../../obj/destdir." host-cpu "/usr/include"
964 " -D_FILE_OFFSET_BITS=64"
965 " -DRUMP_REGISTER_T=int"
966 " -DRUMPUSER_CONFIG=yes"
967 " -DNO_PCI_MSI_MSIX=yes"
968 " -DNUSB_DMA=1"
969 " -DPAE"
970 " -DBUFPAGES=16")
971 "-V" (string-append
972 "CWARNFLAGS="
973 " -Wno-error=maybe-uninitialized"
974 " -Wno-error=address-of-packed-member"
975 " -Wno-error=unused-variable"
976 " -Wno-error=stack-protector"
977 " -Wno-error=array-parameter"
978 " -Wno-error=array-bounds"
979 " -Wno-error=stringop-overflow"
980 " -Wno-error=sign-compare")
981 "-V" "LIBCRTBEGIN="
982 "-V" "LIBCRTEND="
983 "-V" "LIBCRT0="
984 "-V" "LIBCRTI="
985 "-V" "_GCC_CRTENDS="
986 "-V" "_GCC_CRTEND="
987 "-V" "_GCC_CRTBEGINS="
988 "-V" "_GCC_CRTBEGIN="
989 "-V" "_GCC_CRTI="
990 "-V" "_GCC_CRTN="
991 "-U"
992 "-u"
993 "-T" "./obj/tooldir"
994 "-m" host-cpu
995 "-j" (number->string jobs)
996 "tools"
997 "rump"))
998 (with-directory-excursion "buildrump.sh/src/lib/librumpuser"
999 (setenv "RUMPRUN" "true")
1000 (invoke rump-make "dependall"))
1001 (with-directory-excursion "pci-userspace/src-gnu"
1002 (invoke rump-make "dependall")))))
1003 (replace 'install
1004 (lambda _
1005 (define (install-file file target)
1006 (let ((dest (string-append target (basename file))))
1007 (format (current-output-port) "`~a' -> `~a'~%" file dest)
1008 (mkdir-p (dirname dest))
1009 ;; Some libraries are duplicated/copied around in the
1010 ;; build system, do not fail trying to install one
1011 ;; a second time.
1012 (if (file-exists? dest)
1013 (format (current-error-port)
1014 "warning: skipping: ~a\n" file)
1015 (let ((stat (lstat file)))
1016 (case (stat:type stat)
1017 ((symlink)
1018 (let ((target (readlink file)))
1019 (symlink target dest)))
1020 (else
1021 (copy-file file dest)))))))
1022 (let ((header (string-append #$output "/include/rump"))
1023 (lib (string-append #$output "/lib/")))
1024 (mkdir-p header)
1025 (copy-recursively "buildrump.sh/src/sys/rump/include/rump"
1026 header)
1027 (mkdir-p lib)
1028 (for-each
1029 (cute install-file <> lib)
1030 (append (find-files "buildrump.sh/src" "librump.*[.](a|so.*)")
1031 (find-files "obj" "librump.*[.](a|so.*)")))))))))
1032 (inputs
1033 (list gnumach-headers libpciaccess libirqhelp))
1034 (native-inputs
1035 (list autoconf
1036 automake
1037 libgcrypt
1038 (if (%current-target-system)
1039 (cross-mig (%current-target-system))
1040 mig)
1041 zlib))
1042 (supported-systems %hurd-systems)
1043 (home-page "https://wiki.netbsd.org/rumpkernel")
1044 (synopsis "NetBSD as rumpkernel for the GNU/Hurd")
1045 (description
1046 "This package provides NetBSD as rumpkernel for the GNU/Hurd, so that
1047the Hurd may be installed on iron. Using this rumpkernel package, the hurd
1048package's rumpdisk can be built which provides the pci.arbiter and rumpdisk
1049servers.")
1050 (license
1051 ;; The NetBSD rumpkernel code is a big hodgepodge of softwares many of
1052 ;; which have their own different licensing terms, see also
1053 ;; https://salsa.debian.org/hurd-team/rumpkernel/-/blob/master/debian/copyright
1054 (list asl2.0
1055 boost1.0
1056 bsd-2
1057 bsd-3
1058 bsd-4
1059 cddl1.0
1060 expat
1061 gpl1
1062 gpl2+
1063 gpl3+
1064 isc
1065 lgpl2.0+
1066 public-domain
1067 (@ (guix licenses) zlib)
1068 (non-copyleft "file://src/lib/libc/hash/hashhl.c"
1069 "See debian/copyright in the distribution."))))))