Hello! TL; DR: I propose to rebase on master, squash the squash!es, collapse the Reverts, hard reset and => review+finish the rest, merge! So... After about two months in the working, current wip-hurd-vm commit 6a284069188f59553f27760614ffb604b49ec62b squash! linux-boot: Update 'make-hurd-device-nodes'. is finally in a state where it supports building a VM image for the Hurd in three ways. The April-1st hack^H^H^H^method --8<---------------cut here---------------start------------->8--- ./pre-inst-env guix build -f gnu/system/hurd.scm --8<---------------cut here---------------end--------------->8--- => /gnu/store/f1vzgwgxjacn1rd9cpnmpgbv8c5k3rbx-qemu-image still produces a bootable VM, but fails during startup; lacking /boot/activation. Starting the Shepherd from RC was introduced, which broke this. We could spend some effort to resurrect it, but... It was a fun and amazing feat but I think we should remove it before the merge. I don't think we realised how sharp/smart this hack was, navigating cleanly across and through cross-build and qemu-image bugs. The next method is by using --8<---------------cut here---------------start------------->8--- ./pre-inst-env guix system vm-image --no-grafts --target=i586-pc-gnu gnu/system/examples/bare-hurd.tmpl --8<---------------cut here---------------end--------------->8--- => /gnu/store/8pr6qnwl4b5kria0j0hxscv66izc8zpi-qemu-image TODO: address the no-grafts (See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=41350#71) This produces a functional VM, including openssh server. Closures haven't been registered, though, so adding and starting a guix-daemon may not do what we want yet. And lastly the new, preferred method that we finally got working yesterday --8<---------------cut here---------------start------------->8--- ./pre-inst-env guix system disk-image --no-grafts --target=i586-pc-gnu gnu/system/examples/bare-hurd.tmpl --8<---------------cut here---------------end--------------->8--- => /gnu/store/qyq2pj175skkc8kffy5nzfyb47sk3kls-disk-image It should be trivial to add a guix-daemon and do some real work here. Mattieu is looking into cleaning up of --8<---------------cut here---------------start------------->8--- b605a36031 * origin/wip-hurd-vm WIP hurd-directives --8<---------------cut here---------------end--------------->8--- and we also already had a small brain storming on IRC about --8<---------------cut here---------------start------------->8--- dd62341283 * bootloader: grub: Add support for '<hurd-menu-entry>'. ec1dfae81b * system: Add 'hurd' field to <boot-parameters>. 43df8616f6 * bootloader: Add `<hurd-menu-entry>'. --8<---------------cut here---------------end--------------->8--- I guess that before merging, we will want to rewrite this bit, alongside these lines, nicely summarized as --8<---------------cut here---------------start------------->8--- <civodul> so to sum up, the following fields would be added to <menu-entry>: kernel, multiboot-modules <civodul> janneke: it's not GRUB-specific though, in the sense that GRUB closely matches the underlying abstractions <civodul> that is: "multiboot kernel + modules", or "linux + initrd", etc. <civodul> and yes, <boot-parameters> needs to be extended to reflect these addition --8<---------------cut here---------------end--------------->8--- Greetings, janneke PS: I'm starting the VMs like so guix environment --ad-hoc qemu -- qemu-system-i386 -enable-kvm -m 512\ -device rtl8139,netdev=net0 -netdev user,id=net0,hostfwd=tcp:127.0.0.1:10022-:2222\ -snapshot -hda <the-image> -- Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
[-- Attachment #1: Type: text/plain, Size: 503 bytes --] Hello Jan, That's a good summary of the (complex) situation, thank you! > Mattieu is looking into cleaning up of > > b605a36031 * origin/wip-hurd-vm WIP hurd-directives About that, I'd like to limit at maximum the (if hurd ...) conditionals in (gnu system image). So for the "make-device-node", I would propose to "link" it to the image definition, as proposed in the attached patch. I'll see if we can do something similar for the "extra-directives" and the "boot-activation". Thanks, Mathieu [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-hurd-nodes.patch --] [-- Type: text/x-diff, Size: 2821 bytes --] From 371f2bab466cef53f66ac69927014278055572fc Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe <othacehe@gnu.org> Date: Wed, 27 May 2020 10:56:13 +0200 Subject: [PATCH] hurd nodes --- gnu/build/image.scm | 5 +++++ gnu/system/image.scm | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gnu/build/image.scm b/gnu/build/image.scm index 087e2c78d9..d0722616f2 100644 --- a/gnu/build/image.scm +++ b/gnu/build/image.scm @@ -157,6 +157,8 @@ deduplicates files common to CLOSURE and the rest of PREFIX." references-graphs (register-closures? #t) system-directory + (make-device-nodes + make-essential-device-nodes) #:allow-other-keys) "Initialize the given ROOT directory. Use BOOTCFG and BOOTCFG-LOCATION to install the bootloader configuration. @@ -168,6 +170,9 @@ of the directory of the 'system' derivation." (populate-root-file-system system-directory root) (populate-store references-graphs root) + ;; Populate /dev. + (make-device-nodes root) + (when register-closures? (for-each (lambda (closure) (register-closure root diff --git a/gnu/system/image.scm b/gnu/system/image.scm index 03588f7d38..67e560891b 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -89,6 +89,13 @@ (flags '(boot)) (initializer (gexp initialize-root-partition)))) +(define hurd-initialize-root-partition + #~(lambda* (#:rest args) + (apply initialize-root-partition + (append args + (list #:make-device-nodes + make-hurd-device-nodes))))) + (define hurd-disk-image (image (format 'disk-image) @@ -99,7 +106,7 @@ (label root-label) (file-system "ext2") (flags '(boot)) - (initializer (gexp initialize-root-partition))))))) + (initializer hurd-initialize-root-partition)))))) (define efi-disk-image (image @@ -154,12 +161,14 @@ (with-imported-modules `(,@(source-module-closure '((gnu build vm) (gnu build image) + (gnu build linux-boot) (guix store database)) #:select? not-config?) ((guix config) => ,(make-config.scm))) #~(begin (use-modules (gnu build vm) (gnu build image) + (gnu build linux-boot) (guix store database) (guix build utils)) gexp* ...)))) -- 2.26.2
Mathieu Othacehe writes: Hello Mathieu, > That's a good summary of the (complex) situation, thank you! Yeah...well sorry for helping create such a mess :-) >> Mattieu is looking into cleaning up of >> >> b605a36031 * origin/wip-hurd-vm WIP hurd-directives > > About that, I'd like to limit at maximum the (if hurd ...) conditionals > in (gnu system image). Yes, please! > So for the "make-device-node", I would propose to "link" it to the > image definition, as proposed in the attached patch. > > I'll see if we can do something similar for the "extra-directives" and > the "boot-activation". This looks beautiful! It works for me when using this extra ugly patch (yes, it contains an IF that has to go :-) diff --git a/gnu/build/image.scm b/gnu/build/image.scm index 70f1a61b9d..f4727b8bf5 100644 --- a/gnu/build/image.scm +++ b/gnu/build/image.scm @@ -67,7 +67,8 @@ take the partition metadata size into account, take a 25% margin." (define* (make-ext-image partition target root #:key (owner-uid 0) - (owner-gid 0)) + (owner-gid 0) + (options '())) "Handle the creation of EXT2/3/4 partition images. See 'make-partition-image'." (let ((size (partition-size partition)) @@ -82,6 +83,7 @@ take the partition metadata size into account, take a 25% margin." "-E" ,(format #f "root_owner=~a:~a,~a" owner-uid owner-gid journal-options) ,@fs-options + ,@options ,target ,(format #f "~ak" (size-in-kib @@ -105,14 +107,14 @@ take the partition metadata size into account, take a 25% margin." (string-append "::" file)))) (scandir root)))) -(define* (make-partition-image partition-sexp target root) +(define* (make-partition-image partition-sexp target root #:key (options '())) "Create and return the image of PARTITION-SEXP as TARGET. Use the given ROOT directory to populate the image." (let* ((partition (sexp->partition partition-sexp)) (type (partition-file-system partition))) (cond ((string-prefix? "ext" type) - (make-ext-image partition target root)) + (make-ext-image partition target root #:options options)) ((string=? type "vfat") (make-vfat-image partition target root)) (else diff --git a/gnu/system/image.scm b/gnu/system/image.scm index db12a40cb4..3400e01b1a 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -277,13 +277,15 @@ used in the image." (computed-file "partition-image-root" root-builder #:options `(#:references-graphs ,inputs))) (type (partition-file-system partition)) + (options (if (hurd-target?) '("-o" "hurd" "-O" "ext_attr") '())) (image-builder (with-imported-modules* (let ((inputs '#+(list e2fsprogs dosfstools mtools))) (set-path-environment-variable "PATH" '("bin" "sbin") inputs) (make-partition-image #$(partition->gexp partition) #$output - #$image-root))))) + #$image-root + #:options '#$options))))) (computed-file "partition.img" image-builder))) (define (partition->config partition) until the point where it lacks the "/hurd" symlink from the directives. So, apart from removing the IF above in a nice way, we (you?) could try to find a nice way to insert extra-directives > @@ -168,6 +170,9 @@ of the directory of the 'system' derivation." > (populate-root-file-system system-directory root) ^ here I guess...and then we'd be done. I'm not sure as to what extent the extra-directives is/was a kludge? Janneke -- Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
Mathieu Othacehe writes: Hello! > About that, I'd like to limit at maximum the (if hurd ...) conditionals > in (gnu system image). > > So for the "make-device-node", I would propose to "link" it to the > image definition, as proposed in the attached patch. > > I'll see if we can do something similar for the "extra-directives" and > the "boot-activation". I have managed to completely boot-activation. Still using the same patch for hurd-directives, but I've got a feeling we're getting real close now. This adds besides 'multiboot-kernel' and 'multiboot-modules' now also 'multiboot-arguments' to <menu-entry>. The temptation to rename 'linux' and 'linux-arguments' to 'kernel' and 'kernel-arguments' increases, but I didn't! I'm planning to reset wip-hurd-vm again as soon as my tests pass; there was another grub patch on master. Greetings, Janneke -- Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
Hello Jan,
> I have managed to completely boot-activation. Still using the same
> patch for hurd-directives, but I've got a feeling we're getting real
> close now.
Just discovered your (gnu build hurd-boot), that's awesome! I wonder if
we could go one step further and move the "rc" script outside of the
"hurd" package (not sure where to put it though).
Thanks,
Mathieu
Mathieu Othacehe writes: Hello Mathieu, >> I have managed to completely boot-activation. Still using the same >> patch for hurd-directives, but I've got a feeling we're getting real >> close now. > > Just discovered your (gnu build hurd-boot), that's awesome! Thanks...yeah I was just attempting to write a mail about that, asking/wondering if you think some commits should be collapsed again...especially the introduction of using MAKEDEV --8<---------------cut here---------------start------------->8--- Subject: [PATCH 1/9] gnu: hurd: Create minimal "runsystem" script to invoke "rc". diff --git a/gnu/packages/hurd.scm b/gnu/packages/hurd.scm @@ -329,10 +329,26 @@ boot, since this cannot be done from GNU/Linux." [...] + ;; "@HURD@" and "@COREUTILS@" are a placeholders. + (setenv "PATH" "@HURD@/bin:@HURD@/sbin:@COREUTILS@/bin") @@ -349,10 +374,43 @@ boot, since this cannot be done from GNU/Linux." [...] - (invoke "console" "--daemonize" "-c" "/dev/vcs" - "-d" "vga" "-d" "pc_kbd" "-d" "generic_speaker")))) + (format #t "Creating essential device nodes...\n") + (with-directory-excursion "/dev" + (invoke "MAKEDEV" "--devdir=/dev" "std") + (invoke "MAKEDEV" "--devdir=/dev" "vcs") + (invoke "MAKEDEV" "--devdir=/dev" "tty1""tty2" "tty3" "tty4" "tty5" "tty6") + (invoke "MAKEDEV" "--devdir=/dev" "ptyp0" "ptyp1" "ptyp2") + (invoke "MAKEDEV" "--devdir=/dev" "console")) --8<---------------cut here---------------end--------------->8--- later moving it to hurd-boot, and its subsequent removal... > I wonder if we could go one step further and move the "rc" script > outside of the "hurd" package (not sure where to put it though). Yes, I agree that would be great. I briefly thought about it and gave up, instead of asking this question...so The "normal" (old, current master) bootstrap goes like this /hurd/startup -> /libexec/runsystem -> /hurd/init -> /libexec/runsystem.hurd -> /libexec/rc where RC is our initial Guile script. I've managed to patch that into /hurd/startup -> /libexec/runsystem* -> /libexec/rc Where, /hurd is symlink to /gnu/store/*-hurd-0.9/hurd/ and runsystem* now is a very minimal bash script, doing exec /libexec/rc "$@" and /libexecc is currently being substituted with the store file name, which gives us a hurd package that does this /hurd/startup -> /gnu/store/xyz-hurd-0.9/libexec/runsystem -> /gnu/store/xyz-hurd-0.9/libexec/rc Now, how could we have runsystem run another RC? Hmm, runsystem is being called with --load and --system arguments too; we could even give it an --rc=RC-FILE if that's more convenient. Then, we would only need to add this RC-FILE to the system, maybe add a %hurd-"something" service? Hmm. Please share your thoughts, I'm having a go at this. Greetings, Janneke -- Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
> Now, how could we have runsystem run another RC? Hmm, runsystem is
> being called with --load and --system arguments too; we could even
> give it an --rc=RC-FILE if that's more convenient.
>
> Then, we would only need to add this RC-FILE to the system, maybe add a
> %hurd-"something" service?
>
> Hmm. Please share your thoughts, I'm having a go at this.
Having an RC argument passed directly by the bootloader seems like a
good way to proceed for me. This is somehow remotely similar to what we
are doing with the "initrd" on Linux (pointing to some piece of code
that needs to be loaded before starting the init process).
You would also need to store this RC argument in the <boot-parameters>
record, by adding a new field or stuffing it in the "initrd"
field. Then, we wouldn't need an extra service I guess.
If we are going that way, the procedures in (gnu build hurd-boot) could
be passed the "hurd" package to install, and we could maybe get rig of
the "/hurd" symlink?
Thanks,
Mathieu
[-- Attachment #1: Type: text/plain, Size: 1352 bytes --] Mathieu Othacehe writes: Hi Mathieu, > Having an RC argument passed directly by the bootloader seems like a > good way to proceed for me. This is somehow remotely similar to what we > are doing with the "initrd" on Linux (pointing to some piece of code > that needs to be loaded before starting the init process). > > You would also need to store this RC argument in the <boot-parameters> > record, by adding a new field or stuffing it in the "initrd" > field. Then, we wouldn't need an extra service I guess. Hmm...I don't understand...probably I'm missing something. I was thinking to just extend boot-parameters with --rc-file=%hurd-rc-script, and then add %hurd-rc-script to the SYSTEM service...How would I get the RC script into SYSTEM without a service? Anyway...see working prototype attached! To get rid of the extra sevice that I added I'd need some help. Please feel free to just rework it if you like! > If we are going that way, the procedures in (gnu build hurd-boot) could > be passed the "hurd" package to install, and we could maybe get rig of > the "/hurd" symlink? Hehe, that would be nice...but IME /hurd isn't easy to get rid of. The Hurd code uses it "everywhere" and I seem to remember that a simple substitute* on the Hurd archive was not enough...sadly I do not remember the details, so maybe... Greetings, Janneke [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-gnu-services-Add-hurd-startup-service.patch --] [-- Type: text/x-patch, Size: 8200 bytes --] From e11e59cbcd9165e3b885c1019e19aaab471f5498 Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> Date: Thu, 30 Apr 2020 15:40:07 +0200 Subject: [PATCH] gnu: services: Add %hurd-startup-service. This decouples startup of the Hurd from the "hurd" package, moving the RC script into SYSTEM. * gnu/packages/hurd.scm (hurd)[inputs]: Remove hurd-rc-script. [arguments]: Do not substitute it. Update "runsystem.sh" to parse kernel arguments and exec into --rc-file=RC-FILE. (hurd-rc-script): Move to... * gnu/services.scm (%hurd-rc-file): ...this new variable. (bootable-kernel-arguments): Use it. (%hurd-bare-metal-service): New variable. * gnu/system.scm (hurd-default-essential-services): Use it. --- gnu/packages/hurd.scm | 52 ++++++++++--------------------------------- gnu/services.scm | 40 +++++++++++++++++++++++++++++++++ gnu/system.scm | 21 ++++++++++------- 3 files changed, 65 insertions(+), 48 deletions(-) diff --git a/gnu/packages/hurd.scm b/gnu/packages/hurd.scm index 5de4acb1c5..542ca1e229 100644 --- a/gnu/packages/hurd.scm +++ b/gnu/packages/hurd.scm @@ -310,32 +310,6 @@ Hurd-minimal package which are needed for both glibc and GCC.") (base32 "0p2vhnc18cnbmb39vq4m7hzv4mhnm2l0a2s7gx3ar277fwng3hys")))) -(define (hurd-rc-script) - "Return a script to be installed as /libexec/rc in the 'hurd' package. The -script takes care of installing the relevant passive translators on the first -boot, since this cannot be done from GNU/Linux. Then, it runs system -activation; starting the Shepherd." - - (define rc - (with-imported-modules '((guix build utils) - (gnu build hurd-boot) - (guix build syscalls)) - #~(begin - (use-modules (guix build utils) - (gnu build hurd-boot) - (guix build syscalls) - (ice-9 match) - (system repl repl) - (srfi srfi-1) - (srfi srfi-26)) - - (boot-hurd-system)))) - - ;; FIXME: We want the program to use the cross-compiled Guile when - ;; cross-compiling. But why do we need to be explicit here? - (with-parameters ((%current-target-system "i586-pc-gnu")) - (program-file "rc" rc))) - (define dde-sources ;; This is the current tip of the dde branch (let ((commit "ac1c7eb7a8b24b7469bed5365be38a968d59a136")) @@ -417,11 +391,19 @@ PATH=@PATH@ fsck --yes --force / fsysopts / --writable settrans -c /servers/socket/1 /hurd/pflocal -echo Starting /libexec/rc ... -exec /libexec/rc \"$@\" -"))) - )) +# parse multiboot arguments +for i in \"$@\"; do + case $i in + (--rc-file=*) + rc=${i#--rc-file=} + ;; + esac +done + +echo Starting ${rc}... +exec ${rc} \"$@\" +"))))) (add-before 'build 'set-file-names (lambda* (#:key inputs outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) @@ -483,15 +465,6 @@ exec /libexec/rc \"$@\" (mkdir-p datadir) (copy-file "unifont" (string-append datadir "/vga-system.bdf")) - #t))) - (add-after 'install 'install-rc-file - (lambda* (#:key inputs outputs #:allow-other-keys) - (let* ((out (assoc-ref outputs "out")) - (file (string-append out "/libexec/rc")) - (rc (assoc-ref inputs "hurd-rc")) - (coreutils (assoc-ref inputs "coreutils"))) - (delete-file file) - (copy-file rc file) #t)))) #:configure-flags (list (string-append "LDFLAGS=-Wl,-rpath=" %output "/lib") @@ -506,7 +479,6 @@ exec /libexec/rc \"$@\" (build-system gnu-build-system) (inputs `(("glibc-hurd-headers" ,glibc/hurd-headers) - ("hurd-rc" ,(hurd-rc-script)) ("libgcrypt" ,libgcrypt) ;for /hurd/random ("libdaemon" ,libdaemon) ;for /bin/console --daemonize diff --git a/gnu/services.scm b/gnu/services.scm index 4e0bbc0249..b21520eafc 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -94,6 +94,8 @@ activation-service-type activation-service->script %linux-bare-metal-service + %hurd-rc-script + %hurd-startup-service special-files-service-type extra-special-file etc-service-type @@ -630,6 +632,44 @@ ACTIVATION-SCRIPT-TYPE." activation-service-type %linux-kernel-activation)) +;; XXX this won't go into SYSTEM (as system-service); the result is fine +;; though and it gets picked-up well by --rc-file=%hurd-rc-script +(define %hurd-rc-script + ;; The RC script to be started upon boot. + (program-file "rc" + (with-imported-modules '((guix build utils) + (gnu build hurd-boot) + (guix build syscalls)) + #~(begin + (use-modules (guix build utils) + (gnu build hurd-boot) + (guix build syscalls) + (ice-9 match) + (system repl repl) + (srfi srfi-1) + (srfi srfi-26)) + (boot-hurd-system))))) + +(define (hurd-rc-entry mrc) + "Return, as a monadic value, an entry for the RC script in the system +directory." + (mlet %store-monad ((rc mrc)) + (return `(("rc" ,rc))))) + +(define hurd-startup-service-type + ;; The service that creates the initial RC startup file. + (service-type (name 'startup) + (extensions + (list (service-extension system-service-type hurd-rc-entry))) + (compose identity) + (extend (const (lower-object %hurd-rc-script))) + (description + "Produce the operating system's RC script, which is executed +by RUNSYSTEM."))) + +(define %hurd-startup-service + ;; The service that produces the RC script. + (service hurd-startup-service-type #t)) (define special-files-service-type ;; Service to install "special files" such as /bin/sh and /usr/bin/env. diff --git a/gnu/system.scm b/gnu/system.scm index 41c551af0b..09ab574278 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -170,14 +170,18 @@ (define (bootable-kernel-arguments system root-device) "Return a list of kernel arguments (gexps) to boot SYSTEM from ROOT-DEVICE." - (list (string-append "--root=" - ;; Note: Always use the DCE format because that's what - ;; (gnu build linux-boot) expects for the '--root' - ;; kernel command-line option. - (file-system-device->string root-device - #:uuid-type 'dce)) - #~(string-append "--system=" #$system) - #~(string-append "--load=" #$system "/boot"))) + (append + (if (hurd-target?) + (list #~(string-append "--rc-file=" #$%hurd-rc-script)) + '()) + (list (string-append "--root=" + ;; Note: Always use the DCE format because that's what + ;; (gnu build linux-boot) expects for the '--root' + ;; kernel command-line option. + (file-system-device->string root-device + #:uuid-type 'dce)) + #~(string-append "--system=" #$system) + #~(string-append "--load=" #$system "/boot")))) ;; System-wide configuration. ;; TODO: Add per-field docstrings/stexi. @@ -610,6 +614,7 @@ bookkeeping." (define (hurd-default-essential-services os) (list (service system-service-type '()) %boot-service + %hurd-startup-service %activation-service %shepherd-root-service (service user-processes-service-type) -- 2.26.2 [-- Attachment #3: Type: text/plain, Size: 152 bytes --] -- Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
Hi, Jan Nieuwenhuizen <janneke@gnu.org> skribis: >> Having an RC argument passed directly by the bootloader seems like a >> good way to proceed for me. This is somehow remotely similar to what we >> are doing with the "initrd" on Linux (pointing to some piece of code >> that needs to be loaded before starting the init process). >> >> You would also need to store this RC argument in the <boot-parameters> >> record, by adding a new field or stuffing it in the "initrd" >> field. Then, we wouldn't need an extra service I guess. > > Hmm...I don't understand...probably I'm missing something. > > I was thinking to just extend boot-parameters with > --rc-file=%hurd-rc-script, and then add %hurd-rc-script to the SYSTEM > service...How would I get the RC script into SYSTEM without a service? Normally, if you have the system (as returned by ‘guix system build’), that’s enough to derive any other kind of thing you might want. So for example, you could have a “startup” (or “rc”) entry in the ‘system’ directory by extending ‘system-service-type’. And since the system is known from the boot command line, bingo. The guideline IMO should be to remain as close as possible to Guix System on GNU/Linux. It’s OK to depart a bit from upstream Hurd though because those bits are not actually used (Debian does its own thing). >> If we are going that way, the procedures in (gnu build hurd-boot) could >> be passed the "hurd" package to install, and we could maybe get rig of >> the "/hurd" symlink? > > Hehe, that would be nice...but IME /hurd isn't easy to get rid of. Some of the /hurd names are embedded in libc, via the Hurd’s paths.h. Some names are compared by string (!); for instance, symlink.c in libc has: /* A symlink is a file whose translator is "/hurd/symlink\0target\0". */ memcpy (buf, _HURD_SYMLINK, sizeof (_HURD_SYMLINK)); memcpy (&buf[sizeof (_HURD_SYMLINK)], from, len); That makes it next to impossible to remove /hurd. I think it should be treated like /bin/sh and /run/current-system: set up at activation time. >>From e11e59cbcd9165e3b885c1019e19aaab471f5498 Mon Sep 17 00:00:00 2001 > From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> > Date: Thu, 30 Apr 2020 15:40:07 +0200 > Subject: [PATCH] gnu: services: Add %hurd-startup-service. > > This decouples startup of the Hurd from the "hurd" package, moving the RC > script into SYSTEM. > > * gnu/packages/hurd.scm (hurd)[inputs]: Remove hurd-rc-script. > [arguments]: Do not substitute it. Update "runsystem.sh" to parse > kernel arguments and exec into --rc-file=RC-FILE. > (hurd-rc-script): Move to... > * gnu/services.scm (%hurd-rc-file): ...this new variable. > (bootable-kernel-arguments): Use it. > (%hurd-bare-metal-service): New variable. > * gnu/system.scm (hurd-default-essential-services): Use it. […] > +;; XXX this won't go into SYSTEM (as system-service); the result is fine > +;; though and it gets picked-up well by --rc-file=%hurd-rc-script > +(define %hurd-rc-script > + ;; The RC script to be started upon boot. > + (program-file "rc" > + (with-imported-modules '((guix build utils) > + (gnu build hurd-boot) > + (guix build syscalls)) Probably use ‘source-module-closure’ to be on the safe side. > +(define (hurd-rc-entry mrc) > + "Return, as a monadic value, an entry for the RC script in the system > +directory." > + (mlet %store-monad ((rc mrc)) > + (return `(("rc" ,rc))))) > + > +(define hurd-startup-service-type > + ;; The service that creates the initial RC startup file. > + (service-type (name 'startup) > + (extensions > + (list (service-extension system-service-type hurd-rc-entry))) > + (compose identity) > + (extend (const (lower-object %hurd-rc-script))) > + (description > + "Produce the operating system's RC script, which is executed > +by RUNSYSTEM."))) Is this service really meant to be extensible? If not, we could just do: (service-type (name 'startup) (extensions (list (service-extension system-service-type hurd-rc-entry))) (default-value %hurd-rc-script)) where: (define (hurd-rc-entry rc) (mlet %store-monad ((rc (lower-object rc))) (return `(("rc" ,rc))))) > + (append > + (if (hurd-target?) > + (list #~(string-append "--rc-file=" #$%hurd-rc-script)) > + '()) > + (list (string-append "--root=" > + ;; Note: Always use the DCE format because that's what > + ;; (gnu build linux-boot) expects for the '--root' > + ;; kernel command-line option. > + (file-system-device->string root-device > + #:uuid-type 'dce)) > + #~(string-append "--system=" #$system) > + #~(string-append "--load=" #$system "/boot")))) So my suggestion is to avoid --rc-file since you know that SYSTEM/rc exists. Ludo’, who jumps in the middle of the discussion. :-)
[-- Attachment #1: Type: text/plain, Size: 5009 bytes --] Ludovic Courtès writes: Hello! > Jan Nieuwenhuizen <janneke@gnu.org> skribis: > >>> Having an RC argument passed directly by the bootloader seems like a >>> good way to proceed for me. This is somehow remotely similar to what we >>> are doing with the "initrd" on Linux (pointing to some piece of code >>> that needs to be loaded before starting the init process). >>> >>> You would also need to store this RC argument in the <boot-parameters> >>> record, by adding a new field or stuffing it in the "initrd" >>> field. Then, we wouldn't need an extra service I guess. >> >> Hmm...I don't understand...probably I'm missing something. >> >> I was thinking to just extend boot-parameters with >> --rc-file=%hurd-rc-script, and then add %hurd-rc-script to the SYSTEM >> service...How would I get the RC script into SYSTEM without a service? > > Normally, if you have the system (as returned by ‘guix system build’), > that’s enough to derive any other kind of thing you might want. > > So for example, you could have a “startup” (or “rc”) entry in the > ‘system’ directory by extending ‘system-service-type’. And since the > system is known from the boot command line, bingo. > > The guideline IMO should be to remain as close as possible to Guix > System on GNU/Linux. It’s OK to depart a bit from upstream Hurd though > because those bits are not actually used (Debian does its own thing). Okay, that makes sense. Using --system=SYSTEM => SYSTEM/rc now. >>> If we are going that way, the procedures in (gnu build hurd-boot) could >>> be passed the "hurd" package to install, and we could maybe get rig of >>> the "/hurd" symlink? >> >> Hehe, that would be nice...but IME /hurd isn't easy to get rid of. > > Some of the /hurd names are embedded in libc, via the Hurd’s paths.h. > Some names are compared by string (!); for instance, symlink.c in libc > has: > > /* A symlink is a file whose translator is "/hurd/symlink\0target\0". */ > > memcpy (buf, _HURD_SYMLINK, sizeof (_HURD_SYMLINK)); > memcpy (&buf[sizeof (_HURD_SYMLINK)], from, len); > > That makes it next to impossible to remove /hurd. > > I think it should be treated like /bin/sh and /run/current-system: set > up at activation time. Ah right...I think this is exactly what I found (and forgot). The file system embeds the full file-name...that's unfortunate. >> +(define %hurd-rc-script >> + ;; The RC script to be started upon boot. >> + (program-file "rc" >> + (with-imported-modules '((guix build utils) >> + (gnu build hurd-boot) >> + (guix build syscalls)) > > Probably use ‘source-module-closure’ to be on the safe side. Nice! >> +(define (hurd-rc-entry mrc) >> + "Return, as a monadic value, an entry for the RC script in the system >> +directory." >> + (mlet %store-monad ((rc mrc)) >> + (return `(("rc" ,rc))))) >> + >> +(define hurd-startup-service-type >> + ;; The service that creates the initial RC startup file. >> + (service-type (name 'startup) >> + (extensions >> + (list (service-extension system-service-type hurd-rc-entry))) >> + (compose identity) >> + (extend (const (lower-object %hurd-rc-script))) >> + (description >> + "Produce the operating system's RC script, which is executed >> +by RUNSYSTEM."))) > > Is this service really meant to be extensible? If not, we could just do: (no) > (service-type (name 'startup) > (extensions > (list (service-extension system-service-type hurd-rc-entry))) > (default-value %hurd-rc-script)) > > where: > > (define (hurd-rc-entry rc) > (mlet %store-monad ((rc (lower-object rc))) > (return `(("rc" ,rc))))) Thanks, done! >> + (append >> + (if (hurd-target?) >> + (list #~(string-append "--rc-file=" #$%hurd-rc-script)) >> + '()) >> + (list (string-append "--root=" >> + ;; Note: Always use the DCE format because that's what >> + ;; (gnu build linux-boot) expects for the '--root' >> + ;; kernel command-line option. >> + (file-system-device->string root-device >> + #:uuid-type 'dce)) >> + #~(string-append "--system=" #$system) >> + #~(string-append "--load=" #$system "/boot")))) > > So my suggestion is to avoid --rc-file since you know that SYSTEM/rc > exists. Done! > Ludo’, who jumps in the middle of the discussion. :-) Very helpful indeed :-) -- attaching new version (and much tempted to push to wip-hurd-vm now). Any more wishes or ideas, things to be done before merging? Not all patches were reviewed in their current form, I think. Janneke [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: v2-0001-gnu-services-Add-hurd-startup-service.patch --] [-- Type: text/x-patch, Size: 6664 bytes --] From 37c2a57d72f5678ec21a48ed4a3b733a20b71ab1 Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> Date: Thu, 30 Apr 2020 15:40:07 +0200 Subject: [PATCH v2] gnu: services: Add %hurd-startup-service. This decouples startup of the Hurd from the "hurd" package, moving the RC script into SYSTEM. * gnu/packages/hurd.scm (hurd)[inputs]: Remove hurd-rc-script. [arguments]: Do not substitute it. Update "runsystem.sh" to parse kernel arguments and exec into --system=SYSTEM/rc. (hurd-rc-script): Move to... * gnu/services.scm (%hurd-rc-file): ...this new variable. (hurd-rc-entry): New procedure. (%hurd-startup-service): Use it in new variable. * gnu/system.scm (hurd-default-essential-services): Use it. --- gnu/packages/hurd.scm | 52 ++++++++++--------------------------------- gnu/services.scm | 35 +++++++++++++++++++++++++++++ gnu/system.scm | 1 + 3 files changed, 48 insertions(+), 40 deletions(-) diff --git a/gnu/packages/hurd.scm b/gnu/packages/hurd.scm index 5de4acb1c5..9dc03c6c9c 100644 --- a/gnu/packages/hurd.scm +++ b/gnu/packages/hurd.scm @@ -310,32 +310,6 @@ Hurd-minimal package which are needed for both glibc and GCC.") (base32 "0p2vhnc18cnbmb39vq4m7hzv4mhnm2l0a2s7gx3ar277fwng3hys")))) -(define (hurd-rc-script) - "Return a script to be installed as /libexec/rc in the 'hurd' package. The -script takes care of installing the relevant passive translators on the first -boot, since this cannot be done from GNU/Linux. Then, it runs system -activation; starting the Shepherd." - - (define rc - (with-imported-modules '((guix build utils) - (gnu build hurd-boot) - (guix build syscalls)) - #~(begin - (use-modules (guix build utils) - (gnu build hurd-boot) - (guix build syscalls) - (ice-9 match) - (system repl repl) - (srfi srfi-1) - (srfi srfi-26)) - - (boot-hurd-system)))) - - ;; FIXME: We want the program to use the cross-compiled Guile when - ;; cross-compiling. But why do we need to be explicit here? - (with-parameters ((%current-target-system "i586-pc-gnu")) - (program-file "rc" rc))) - (define dde-sources ;; This is the current tip of the dde branch (let ((commit "ac1c7eb7a8b24b7469bed5365be38a968d59a136")) @@ -417,11 +391,19 @@ PATH=@PATH@ fsck --yes --force / fsysopts / --writable settrans -c /servers/socket/1 /hurd/pflocal -echo Starting /libexec/rc ... -exec /libexec/rc \"$@\" -"))) - )) +# parse multiboot arguments +for i in \"$@\"; do + case $i in + (--system=*) + system=${i#--system=} + ;; + esac +done + +echo Starting ${system}/rc... +exec ${system}/rc \"$@\" +"))))) (add-before 'build 'set-file-names (lambda* (#:key inputs outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) @@ -483,15 +465,6 @@ exec /libexec/rc \"$@\" (mkdir-p datadir) (copy-file "unifont" (string-append datadir "/vga-system.bdf")) - #t))) - (add-after 'install 'install-rc-file - (lambda* (#:key inputs outputs #:allow-other-keys) - (let* ((out (assoc-ref outputs "out")) - (file (string-append out "/libexec/rc")) - (rc (assoc-ref inputs "hurd-rc")) - (coreutils (assoc-ref inputs "coreutils"))) - (delete-file file) - (copy-file rc file) #t)))) #:configure-flags (list (string-append "LDFLAGS=-Wl,-rpath=" %output "/lib") @@ -506,7 +479,6 @@ exec /libexec/rc \"$@\" (build-system gnu-build-system) (inputs `(("glibc-hurd-headers" ,glibc/hurd-headers) - ("hurd-rc" ,(hurd-rc-script)) ("libgcrypt" ,libgcrypt) ;for /hurd/random ("libdaemon" ,libdaemon) ;for /bin/console --daemonize diff --git a/gnu/services.scm b/gnu/services.scm index 4e0bbc0249..5a04964790 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -94,6 +94,8 @@ activation-service-type activation-service->script %linux-bare-metal-service + %hurd-rc-script + %hurd-startup-service special-files-service-type extra-special-file etc-service-type @@ -630,6 +632,39 @@ ACTIVATION-SCRIPT-TYPE." activation-service-type %linux-kernel-activation)) +(define %hurd-rc-script + ;; The RC script to be started upon boot. + (program-file "rc" + (with-imported-modules (source-module-closure + '((guix build utils) + (gnu build hurd-boot) + (guix build syscalls))) + #~(begin + (use-modules (guix build utils) + (gnu build hurd-boot) + (guix build syscalls) + (ice-9 match) + (system repl repl) + (srfi srfi-1) + (srfi srfi-26)) + (boot-hurd-system))))) + +(define (hurd-rc-entry rc) + "Return, as a monadic value, an entry for the RC script in the system +directory." + (mlet %store-monad ((rc (lower-object rc))) + (return `(("rc" ,rc))))) + +(define hurd-startup-service-type + ;; The service that creates the initial SYSTEM/rc startup file. + (service-type (name 'startup) + (extensions + (list (service-extension system-service-type hurd-rc-entry))) + (default-value %hurd-rc-script))) + +(define %hurd-startup-service + ;; The service that produces the RC script. + (service hurd-startup-service-type %hurd-rc-script)) (define special-files-service-type ;; Service to install "special files" such as /bin/sh and /usr/bin/env. diff --git a/gnu/system.scm b/gnu/system.scm index 41c551af0b..c20f4649f9 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -610,6 +610,7 @@ bookkeeping." (define (hurd-default-essential-services os) (list (service system-service-type '()) %boot-service + %hurd-startup-service %activation-service %shepherd-root-service (service user-processes-service-type) -- 2.26.2 [-- Attachment #3: Type: text/plain, Size: 152 bytes --] -- Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
Hi,
Jan Nieuwenhuizen <janneke@gnu.org> skribis:
> From 37c2a57d72f5678ec21a48ed4a3b733a20b71ab1 Mon Sep 17 00:00:00 2001
> From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org>
> Date: Thu, 30 Apr 2020 15:40:07 +0200
> Subject: [PATCH v2] gnu: services: Add %hurd-startup-service.
>
> This decouples startup of the Hurd from the "hurd" package, moving the RC
> script into SYSTEM.
>
> * gnu/packages/hurd.scm (hurd)[inputs]: Remove hurd-rc-script.
> [arguments]: Do not substitute it. Update "runsystem.sh" to parse kernel
> arguments and exec into --system=SYSTEM/rc.
> (hurd-rc-script): Move to...
> * gnu/services.scm (%hurd-rc-file): ...this new variable.
> (hurd-rc-entry): New procedure.
> (%hurd-startup-service): Use it in new variable.
> * gnu/system.scm (hurd-default-essential-services): Use it.
LGTM, thank you!
Ludo’.
Ludovic Courtès writes: >> From 37c2a57d72f5678ec21a48ed4a3b733a20b71ab1 Mon Sep 17 00:00:00 2001 >> From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> >> Date: Thu, 30 Apr 2020 15:40:07 +0200 >> Subject: [PATCH v2] gnu: services: Add %hurd-startup-service. >> >> This decouples startup of the Hurd from the "hurd" package, moving the RC >> script into SYSTEM. >> >> * gnu/packages/hurd.scm (hurd)[inputs]: Remove hurd-rc-script. >> [arguments]: Do not substitute it. Update "runsystem.sh" to parse kernel >> arguments and exec into --system=SYSTEM/rc. >> (hurd-rc-script): Move to... >> * gnu/services.scm (%hurd-rc-file): ...this new variable. >> (hurd-rc-entry): New procedure. >> (%hurd-startup-service): Use it in new variable. >> * gnu/system.scm (hurd-default-essential-services): Use it. > > LGTM, thank you! Great...pushed to wip-hurd-vm. So...in the hope that this is helpful I created an overview of all of current wip-hurd-vm. Legend (in order of merge'ability / is there a convention for this?): [M] Mathieu [L] Ludo g good to go LGTM'd t trivial (self-LGTM :-) . direct dependency of/partially superseded by a LGTM ack or review needed ! troublesome My take on wip-hurd-vm: g 37c2a57d72 gnu: services: Add %hurd-startup-service. . ef647de139 hurd-boot: Use setxattr instead of MAKEDEV. . 27f049273f hurd-boot: Further cleanup of "rc". b73d83f217 syscalls: set-thread-name, thread-name: Stub for the Hurd. t 60a510741c system: bare-hurd.tmpl: Add openssh client and service. t 57c16e4e6a system: hurd: Remove 'cross-hurd-image' hack. . f287c8992a system: hurd: Populate services. g ac0fc836a2 services: Add `hurd-getty-service-type'. g e28364ea2d services: Add `hurd-console-service-type'. . 8e31888648 gnu: hurd: Create minimal "runsystem" script to invoke "rc". 17638f3b4d services: hurd: Use activation-service, hurd-etc-service. 6ed827c281 system: Add `hurd-activation'. 83a245a8e0 services: hurd: Add `hurd-etc-service'. d04e51d196 system: examples: Add bare-hurd.tmpl. t b8bccce071 system: Use 'hurd' package in label. g cf92e7393b bootloader: grub: Add support for multiboot. g 1a236d1535 system: Add 'multiboot-modules' field to <boot-parameters>. g 6a6fc5fd64 bootloader: Extend `<menu-entry>' for multiboot. dd0a930ea8 system: Add 'hurd' field to <operating-system>. da3afc95f4 system: hurd: Add hurd-default-essential-services. ! ee81319934 image: Support extra-directives, add hurd-directives. t 4479c1c1e3 linux-boot: Update 'make-hurd-device-nodes'. [M] a17f91bd50 image: Add Hurd support. t 7359403993 gnu: hurd: Update to upstream Hurd-reserved xattr index. [L] 68a8a26a57 gnu: guile-static: Disable JIT on ARMv7. [L] 220243a2c6 vm: Shared-store script runs that native QEMU and Bash. [L] e3b6c5dce2 vm: <virtual-machine> compiler honors system and target. [L] d43423f074 vm: 'qemu-image' preserves the cross-compilation target of the OS. [L] c6ee3a059b vm: 'qemu-image' uses the native partitioning tools and bootloader. [L] ab06638f57 vm: 'expression->derivation-in-linux-vm' always returns a native build. [L] 113ba9d7a9 system: 'system-linux-image-file-name' takes an optional parameter. Hoping this is helpful, Greetings, Janneke -- Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
Hey! > Legend (in order of merge'ability / is there a convention for this?): > > [M] Mathieu > [L] Ludo > g good to go LGTM'd > t trivial (self-LGTM :-) > . direct dependency of/partially superseded by a LGTM > > ack or review needed > ! troublesome Hehe, nice one :) > ! ee81319934 image: Support extra-directives, add hurd-directives. This one now only contains the hurd symlink, that you could be done at activation I guess. > t 4479c1c1e3 linux-boot: Update 'make-hurd-device-nodes'. > [M] a17f91bd50 image: Add Hurd support. > t 7359403993 gnu: hurd: Update to upstream Hurd-reserved xattr index. > [L] 68a8a26a57 gnu: guile-static: Disable JIT on ARMv7. > [L] 220243a2c6 vm: Shared-store script runs that native QEMU and Bash. > [L] e3b6c5dce2 vm: <virtual-machine> compiler honors system and target. > [L] d43423f074 vm: 'qemu-image' preserves the cross-compilation target of the OS. > [L] c6ee3a059b vm: 'qemu-image' uses the native partitioning tools and bootloader. > [L] ab06638f57 vm: 'expression->derivation-in-linux-vm' always returns a native build. > [L] 113ba9d7a9 system: 'system-linux-image-file-name' takes an optional parameter. For the rest, maybe you could send a patch serie by email with all the patch that are tagged ' ' or '!'. This way we could proceed to a last review round? Thanks, Mathieu
Mathieu Othacehe writes: Hi! >> Legend (in order of merge'ability / is there a convention for this?): >> >> [M] Mathieu >> [L] Ludo >> g good to go LGTM'd >> t trivial (self-LGTM :-) >> . direct dependency of/partially superseded by a LGTM >> >> ack or review needed >> ! troublesome > > Hehe, nice one :) > >> ! ee81319934 image: Support extra-directives, add hurd-directives. > > This one now only contains the hurd symlink, that you could be done at > activation I guess. I never believed that could work, but to my own eh, ..., I found a way to make it work. We "only" need to make sure that /hurd/startup etc. are found by substitute*'ing some more, and create the symlink. Reverting that patch and using this diff --8<---------------cut here---------------start------------->8--- diff --git a/gnu/build/hurd-boot.scm b/gnu/build/hurd-boot.scm index 20d012fbfa..31260b52a1 100644 --- a/gnu/build/hurd-boot.scm +++ b/gnu/build/hurd-boot.scm @@ -45,6 +45,35 @@ Return the value associated with OPTION, or #f on failure." (lambda (arg) (substring arg (+ 1 (string-index arg #\=))))))) +;; XXX FIXME c&p from guix/utils.scm +(define (readlink* file) + "Call 'readlink' until the result is not a symlink." + (define %max-symlink-depth 50) + + (let loop ((file file) + (depth 0)) + (define (absolute target) + (if (absolute-file-name? target) + target + (string-append (dirname file) "/" target))) + + (if (>= depth %max-symlink-depth) + file + (call-with-values + (lambda () + (catch 'system-error + (lambda () + (values #t (readlink file))) + (lambda args + (let ((errno (system-error-errno args))) + (if (or (= errno EINVAL)) + (values #f file) + (apply throw args)))))) + (lambda (success? target) + (if success? + (loop (absolute target) (+ depth 1)) + file)))))) + (define* (make-hurd-device-nodes #:optional (root "/")) "Make some of the nodes needed on GNU/Hurd." (define (scope dir) @@ -199,18 +228,25 @@ XXX TODO: use Linux xattr/setxattr to remove (settrans in) /libexec/RUNSYSTEM (format #t "Setting-up essential translators...\n") (set-hurd-device-translators) - (format #t "Starting pager...\n") - (unless (zero? (system* "/hurd/mach-defpager")) - (format #t "FAILED...Good luck!\n")) - (let* ((args (command-line)) (system (find-long-option "--system" args)) (to-load (find-long-option "--load" args))) + (false-if-exception (delete-file "/run/current-system")) (format #t "Setting current system...~a\n" system) (mkdir-p "/run") (symlink system "/run/current-system") + + (false-if-exception (delete-file "/hurd")) + (let ((hurd/hurd (readlink* (string-append system "/profile/hurd")))) + (symlink hurd/hurd "/hurd")) + + (format #t "Starting pager...\n") + (unless (zero? (system* "/hurd/mach-defpager")) + (format #t "FAILED...Good luck!\n")) + (cond ((member "--repl" args) + (format #t "Starting repl...\n") (start-repl)) (to-load (format #t "loading '~a'...\n" to-load) diff --git a/gnu/packages/hurd.scm b/gnu/packages/hurd.scm index 9dc03c6c9c..087574cd61 100644 --- a/gnu/packages/hurd.scm +++ b/gnu/packages/hurd.scm @@ -390,6 +390,8 @@ PATH=@PATH@ fsck --yes --force / fsysopts / --writable + +# Note: this /hurd/ gets substituted settrans -c /servers/socket/1 /hurd/pflocal # parse multiboot arguments @@ -421,9 +423,18 @@ exec ${system}/rc \"$@\" (substitute* '("utils/uptime.sh") (("/bin/w") (string-append out "/bin/w"))) - (substitute* "daemons/console-run.c" + (substitute* '("boot/boot.c" + "daemons/console-run.c" + "startup/startup.c") (("/hurd/") (string-append out "/hurd/"))) + (substitute* "hurd/paths.h" + (("_HURD_STARTUP\t") + (string-append "_HURD_STARTUP\t\"" out "\" ")) + (("_HURD_PROC\t") + (string-append "_HURD_PROC\t\"" out "\" ")) + (("_HURD_AUTH\t") + (string-append "_HURD_AUTH\t\"" out "\" "))) (substitute* '("daemons/runsystem.sh" "sutils/MAKEDEV.sh") (("^PATH=.*") --8<---------------cut here---------------end--------------->8--- produces a bootable VM. So...this could be great or maybe...well, what do you think? >> t 4479c1c1e3 linux-boot: Update 'make-hurd-device-nodes'. >> [M] a17f91bd50 image: Add Hurd support. >> t 7359403993 gnu: hurd: Update to upstream Hurd-reserved xattr index. >> [L] 68a8a26a57 gnu: guile-static: Disable JIT on ARMv7. >> [L] 220243a2c6 vm: Shared-store script runs that native QEMU and Bash. >> [L] e3b6c5dce2 vm: <virtual-machine> compiler honors system and target. >> [L] d43423f074 vm: 'qemu-image' preserves the cross-compilation target of the OS. >> [L] c6ee3a059b vm: 'qemu-image' uses the native partitioning tools and bootloader. >> [L] ab06638f57 vm: 'expression->derivation-in-linux-vm' always returns a native build. >> [L] 113ba9d7a9 system: 'system-linux-image-file-name' takes an optional parameter. > > For the rest, maybe you could send a patch serie by email with all the > patch that are tagged ' ' or '!'. This way we could proceed to a last > review round? Sure, that makes sense. I'll need some time to move this diff down the tree and do some testing. Greetings, Janneke -- Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
Hi!
Jan Nieuwenhuizen <janneke@gnu.org> skribis:
> --- a/gnu/packages/hurd.scm
> +++ b/gnu/packages/hurd.scm
> @@ -390,6 +390,8 @@ PATH=@PATH@
>
> fsck --yes --force /
> fsysopts / --writable
> +
> +# Note: this /hurd/ gets substituted
> settrans -c /servers/socket/1 /hurd/pflocal
>
> # parse multiboot arguments
> @@ -421,9 +423,18 @@ exec ${system}/rc \"$@\"
> (substitute* '("utils/uptime.sh")
> (("/bin/w")
> (string-append out "/bin/w")))
> - (substitute* "daemons/console-run.c"
> + (substitute* '("boot/boot.c"
> + "daemons/console-run.c"
> + "startup/startup.c")
> (("/hurd/")
> (string-append out "/hurd/")))
> + (substitute* "hurd/paths.h"
> + (("_HURD_STARTUP\t")
> + (string-append "_HURD_STARTUP\t\"" out "\" "))
> + (("_HURD_PROC\t")
> + (string-append "_HURD_PROC\t\"" out "\" "))
> + (("_HURD_AUTH\t")
> + (string-append "_HURD_AUTH\t\"" out "\" ")))
> (substitute* '("daemons/runsystem.sh"
> "sutils/MAKEDEV.sh")
> (("^PATH=.*")
>
> produces a bootable VM. So...this could be great or maybe...well, what
> do you think?
As discussed on IRC, I wonder if changing <hurd/paths.h> is a good idea
because it’s captured by libc, etc. So it could have the effect of
forcing all the applications to refer to /gnu/store/…-old-hurd instead
of using the (typically more up-to-date) /hurd.
It could also lead to setting /gnu/store/…-old-hurd as passive
translator settings, which would be very bad because
/gnu/store/…-old-hurd could be GC’d (the GC doesn’t scan passive
translator settings and probably never will).
Thanks,
Ludo’.
Ludovic Courtès writes: Hello! > Jan Nieuwenhuizen <janneke@gnu.org> skribis: > >> --- a/gnu/packages/hurd.scm >> +++ b/gnu/packages/hurd.scm [...] >> + (substitute* "hurd/paths.h" >> + (("_HURD_STARTUP\t") >> + (string-append "_HURD_STARTUP\t\"" out "\" ")) >> + (("_HURD_PROC\t") >> + (string-append "_HURD_PROC\t\"" out "\" ")) >> + (("_HURD_AUTH\t") >> + (string-append "_HURD_AUTH\t\"" out "\" "))) >> (substitute* '("daemons/runsystem.sh" >> "sutils/MAKEDEV.sh") >> (("^PATH=.*") >> >> produces a bootable VM. So...this could be great or maybe...well, what >> do you think? > > As discussed on IRC, I wonder if changing <hurd/paths.h> is a good idea > because it’s captured by libc, etc. Thank you for explaining it on IRC and stating it so clearly here again; this really helped me! > So it could have the effect of > forcing all the applications to refer to /gnu/store/…-old-hurd instead > of using the (typically more up-to-date) /hurd. > > It could also lead to setting /gnu/store/…-old-hurd as passive > translator settings, which would be very bad because > /gnu/store/…-old-hurd could be GC’d (the GC doesn’t scan passive > translator settings and probably never will). Ah...right. As discussed on IRC, I already tried only using a fixed file-name for _HURD_STARTUP (out + "/hurd/startup"); which worked. So, after digesting your message here I took the next step: grep for _HURD_STARTUP and change it there, like so diff --git a/gnu/packages/hurd.scm b/gnu/packages/hurd.scm index 421783eb80..8c73ea8430 100644 --- a/gnu/packages/hurd.scm +++ b/gnu/packages/hurd.scm @@ -428,9 +428,10 @@ exec ${system}/rc \"$@\" "startup/startup.c") (("/hurd/") (string-append out "/hurd/"))) - (substitute* "hurd/paths.h" - (("_HURD_STARTUP\t") - (string-append "_HURD_STARTUP\t\"" out "\" "))) + (substitute* '("libdiskfs/boot-start.c" + "libdiskfs/opts-std-startup.c") + (("_HURD_STARTUP") + (string-append "\"" out "/hurd/startup\""))) This also works, and so I figure we're fine now. I'm resetting wip-hurd-vm and, like Mathieu suggested will prepare to send send a patch series here for the unreviewed subset of patches. Greetings, Janneke -- Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
From: Jan Nieuwenhuizen <janneke@gnu.org> Hi! I've just reset wip-hurd-vm (and already locally fixed one commit message using a report by jonsger). This patch set includes all patches that I haven't seen any comments on yet. "wip-hurd-vm" is currently 23 commits and I believe we're good to go after this review. This patch set also includes the already reviewed three <menu-entry>, <boot-parameters> and grub patches that I don't expect/need an explicit LGTM on (of course I still take remarks/suggestions if you feel the need). I based the previous version of wip-hurd-vm onto Ludo's qemu-image work, mainly to see if it would fix the old vm-image, and make sure that it would not break anything. While I would still suggest to merge that work, I have removed it from wip-hurd-vm; the only supported way to build a VM image for the Hurd is by using the new disk-image. Thanks, Janneke Jan (janneke) Nieuwenhuizen (8): system: Add 'hurd' field to <operating-system>. bootloader: Extend `<menu-entry>' for multiboot. system: Add 'multiboot-modules' field to <boot-parameters>. bootloader: grub: Add support for multiboot. system: Use 'hurd' package in label. system: examples: Add bare-hurd.tmpl. services: hurd: Add `hurd-etc-service'. system: Add `hurd-activation'. Makefile.am | 3 +- doc/guix.texi | 26 ++++++- gnu/bootloader.scm | 49 +++++++++++-- gnu/bootloader/grub.scm | 71 +++++++++++-------- gnu/build/activation.scm | 9 +-- gnu/local.mk | 1 + gnu/services.scm | 86 +++++++++++++++-------- gnu/services/hurd.scm | 61 +++++++++++++++++ gnu/system.scm | 106 +++++++++++++++++++++++------ gnu/system/examples/bare-hurd.tmpl | 24 +++++++ gnu/system/hurd.scm | 50 +++++++++++++- 11 files changed, 394 insertions(+), 92 deletions(-) create mode 100644 gnu/services/hurd.scm create mode 100644 gnu/system/examples/bare-hurd.tmpl -- 2.26.2
* gnu/system.scm (<operating-system>)[hurd]: New field. * doc/guix.texi (operating-system Reference): Document 'hurd'. --- doc/guix.texi | 13 ++++++++++--- gnu/system.scm | 3 +++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 056bf011f6..4776eacacd 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -11484,9 +11484,16 @@ configuration (@pxref{Using the Configuration System}). @table @asis @item @code{kernel} (default: @code{linux-libre}) -The package object of the operating system kernel to use@footnote{Currently -only the Linux-libre kernel is supported. In the future, it will be -possible to use the GNU@tie{}Hurd.}. +The package object of the operating system kernel to +use@footnote{Currently only the Linux-libre kernel is fully supported. +Using GNU@tie{}mach in combination with a @code{hurd} is experimental +and only available when building a vm-image.}. + +@cindex hurd +@item @code{hurd} (default: @code{#f}) +The hurd to be started by the kernel. This is required to build an +experimental vm-image for the Hurd and requires using @code{kernel} +GNU@tie{}mach as well as other specific operating system overrides. @item @code{kernel-loadable-modules} (default: '()) A list of objects (usually packages) to collect loadable kernel modules diff --git a/gnu/system.scm b/gnu/system.scm index 213452a6f9..43dd2ec598 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -83,6 +83,7 @@ operating-system-packages operating-system-host-name operating-system-hosts-file + operating-system-hurd operating-system-kernel operating-system-kernel-file operating-system-kernel-arguments @@ -187,6 +188,8 @@ (default '())) ; list of packages (kernel-arguments operating-system-user-kernel-arguments (default %default-kernel-arguments)) ; list of gexps/strings + (hurd operating-system-hurd + (default #f)) ; package (bootloader operating-system-bootloader) ; <bootloader-configuration> (label operating-system-label ; string (thunked) -- 2.26.2
* gnu/bootloader.scm (<menu-entry>)[multiboot-kernel,multiboot-arguments, multiboot-modules]: New fields. [linux,initrd]: Add default value '#f'. (menu-entry->sexp, sexp->menu-entry): Support multiboot entry. --- gnu/bootloader.scm | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm index 668caa7fc3..2eebb8e9d9 100644 --- a/gnu/bootloader.scm +++ b/gnu/bootloader.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe@gmail.com> ;;; Copyright © 2017 Leo Famulari <leo@famulari.name> ;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -33,6 +34,9 @@ menu-entry-linux-arguments menu-entry-initrd menu-entry-device-mount-point + menu-entry-multiboot-kernel + menu-entry-multiboot-arguments + menu-entry-multiboot-modules menu-entry->sexp sexp->menu-entry @@ -77,22 +81,41 @@ (default #f)) (device-mount-point menu-entry-device-mount-point (default #f)) - (linux menu-entry-linux) + (linux menu-entry-linux + (default #f)) (linux-arguments menu-entry-linux-arguments (default '())) ; list of string-valued gexps - (initrd menu-entry-initrd)) ; file name of the initrd as a gexp + (initrd menu-entry-initrd ; file name of the initrd as a gexp + (default #f)) + (multiboot-kernel menu-entry-multiboot-kernel + (default #f)) + (multiboot-arguments menu-entry-multiboot-arguments + (default '())) ; list of string-valued gexps + (multiboot-modules menu-entry-multiboot-modules + (default '()))) ; list of multiboot commands, where + ; a command is a list of <string> (define (menu-entry->sexp entry) "Return ENTRY serialized as an sexp." (match entry - (($ <menu-entry> label device mount-point linux linux-arguments initrd) + (($ <menu-entry> label device mount-point linux linux-arguments initrd #f + ()) `(menu-entry (version 0) (label ,label) (device ,device) (device-mount-point ,mount-point) (linux ,linux) (linux-arguments ,linux-arguments) - (initrd ,initrd))))) + (initrd ,initrd))) + (($ <menu-entry> label device mount-point #f () #f + multiboot-kernel multiboot-arguments multiboot-modules) + `(menu-entry (version 0) + (label ,label) + (device ,device) + (device-mount-point ,mount-point) + (multiboot-kernel ,multiboot-kernel) + (multiboot-arguments ,multiboot-arguments) + (multiboot-modules ,multiboot-modules))))) (define (sexp->menu-entry sexp) "Turn SEXP, an sexp as returned by 'menu-entry->sexp', into a <menu-entry> @@ -109,7 +132,20 @@ record." (device-mount-point mount-point) (linux linux) (linux-arguments linux-arguments) - (initrd initrd))))) + (initrd initrd))) + (('menu-entry ('version 0) + ('label label) ('device device) + ('device-mount-point mount-point) + ('multiboot-kernel multiboot-kernel) + ('multiboot-arguments multiboot-arguments) + ('multiboot-modules multiboot-modules) _ ...) + (menu-entry + (label label) + (device device) + (device-mount-point mount-point) + (multiboot-kernel multiboot-kernel) + (multiboot-arguments multiboot-arguments) + (multiboot-modules multiboot-modules))))) \f ;;; -- 2.26.2
* gnu/system.scm (<boot-parameters>)[multiboot-modules]: New field. (read-boot-parameters): Initialize it. (operating-system-multiboot-modules, hurd-multiboot-modules): New procedure. (operating-system-boot-parameters): Cater for multiboot the Hurd and initialize it; avoid initrd in that case. (operating-system-kernel-file): Cater for for Gnumach (the Hurd) besides Linux. (boot-parameters->menu-entry): Use it to support a multiboot <menu-entry>. --- gnu/system.scm | 92 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 73 insertions(+), 19 deletions(-) diff --git a/gnu/system.scm b/gnu/system.scm index 43dd2ec598..a96a6e6f2c 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -39,9 +39,11 @@ #:use-module (guix utils) #:use-module (gnu packages base) #:use-module (gnu packages bash) + #:use-module (gnu packages cross-base) #:use-module (gnu packages guile) #:use-module (gnu packages guile-xyz) #:use-module (gnu packages admin) + #:use-module (gnu packages hurd) #:use-module (gnu packages linux) #:use-module (gnu packages pciutils) #:use-module (gnu packages package-management) @@ -142,6 +144,7 @@ boot-parameters-kernel boot-parameters-kernel-arguments boot-parameters-initrd + boot-parameters-multiboot-modules read-boot-parameters read-boot-parameters-file boot-parameters->menu-entry @@ -283,7 +286,8 @@ directly by the user." (store-mount-point boot-parameters-store-mount-point) (kernel boot-parameters-kernel) (kernel-arguments boot-parameters-kernel-arguments) - (initrd boot-parameters-initrd)) + (initrd boot-parameters-initrd) + (multiboot-modules boot-parameters-multiboot-modules)) (define (ensure-not-/dev device) "If DEVICE starts with a slash, return #f. This is meant to filter out @@ -314,7 +318,7 @@ file system labels." (match (read port) (('boot-parameters ('version 0) ('label label) ('root-device root) - ('kernel linux) + ('kernel kernel) rest ...) (boot-parameters (label label) @@ -330,12 +334,12 @@ file system labels." ((_ entries) (map sexp->menu-entry entries)) (#f '()))) - ;; In the past, we would store the directory name of the kernel instead - ;; of the absolute file name of its image. Detect that and correct it. - (kernel (if (string=? linux (direct-store-path linux)) - (string-append linux "/" + ;; In the past, we would store the directory name of linux instead of + ;; the absolute file name of its image. Detect that and correct it. + (kernel (if (string=? kernel (direct-store-path kernel)) + (string-append kernel "/" (system-linux-image-file-name)) - linux)) + kernel)) (kernel-arguments (match (assq 'kernel-arguments rest) @@ -349,6 +353,8 @@ file system labels." (('initrd (? string? file)) file))) + (multiboot-modules (or (assq 'multiboot-modules rest) '())) + (store-device ;; Linux device names like "/dev/sda1" are not suitable GRUB device ;; identifiers, so we just filter them out. @@ -386,14 +392,25 @@ The object has its kernel-arguments extended in order to make it bootable." (boot-parameters-kernel-arguments params)))))) (define (boot-parameters->menu-entry conf) - (menu-entry - (label (boot-parameters-label conf)) - (device (boot-parameters-store-device conf)) - (device-mount-point (boot-parameters-store-mount-point conf)) - (linux (boot-parameters-kernel conf)) - (linux-arguments (boot-parameters-kernel-arguments conf)) - (initrd (boot-parameters-initrd conf)))) - + (let* ((kernel (boot-parameters-kernel conf)) + (multiboot-modules (boot-parameters-multiboot-modules conf)) + (multiboot? (pair? multiboot-modules))) + (menu-entry + (label (boot-parameters-label conf)) + (device (boot-parameters-store-device conf)) + (device-mount-point (boot-parameters-store-mount-point conf)) + (linux (and (not multiboot?) kernel)) + (linux-arguments (if (not multiboot?) ' + (boot-parameters-kernel-arguments conf) + '())) + (initrd (boot-parameters-initrd conf)) + (multiboot-kernel (and multiboot? kernel)) + (multiboot-arguments (if multiboot? + (boot-parameters-kernel-arguments conf) + '())) + (multiboot-modules (if multiboot? + (boot-parameters-multiboot-modules conf) + '()))))) \f ;;; @@ -485,8 +502,17 @@ from the initrd." (define (operating-system-kernel-file os) "Return an object representing the absolute file name of the kernel image of OS." - (file-append (operating-system-kernel os) - "/" (system-linux-image-file-name))) + (if (operating-system-hurd os) + (let* ((mach (operating-system-kernel os)) + (mach (if (%current-target-system) + ;; A cross-built GNUmach does not work + (with-parameters ((%current-system "i686-linux") + (%current-target-system #f)) + mach) + mach))) + (file-append mach "/boot/gnumach")) + (file-append (operating-system-kernel os) + "/" (system-linux-image-file-name)))) (define (package-for-kernel target-kernel module-package) "Return a package like MODULE-PACKAGE, adapted for TARGET-KERNEL, if @@ -1131,17 +1157,44 @@ a list of <menu-entry>, to populate the \"old entries\" menu." #:store-directory-prefix (btrfs-store-subvolume-file-name file-systems)))) +(define (operating-system-multiboot-modules os) + (if (operating-system-hurd os) (hurd-multiboot-modules os) '())) + +(define (hurd-multiboot-modules os) + (let* ((hurd (operating-system-hurd os)) + (root-file-system-command + (list (file-append hurd "/hurd/ext2fs.static") + "ext2fs" + "--multiboot-command-line='${kernel-command-line}'" + "--host-priv-port='${host-port}'" + "--device-master-port='${device-port}'" + "--exec-server-task='${exec-task}'" + "--store-type=typed" + "--x-xattr-translator-records" + "'${root}'" "'$(task-create)'" "'$(task-resume)'")) + (target (%current-target-system)) + (libc (if target + (with-parameters ((%current-target-system #f)) + (cross-libc target)) + glibc)) + (exec-server-command + (list (file-append libc "/lib/ld.so.1") "exec" + (file-append hurd "/hurd/exec") "'$(exec-task=task-create)'"))) + (list root-file-system-command exec-server-command))) + (define* (operating-system-boot-parameters os root-device #:key system-kernel-arguments?) "Return a monadic <boot-parameters> record that describes the boot parameters of OS. When SYSTEM-KERNEL-ARGUMENTS? is true, add kernel arguments such as '--root' and '--load' to <boot-parameters>." - (let* ((initrd (operating-system-initrd-file os)) + (let* ((initrd (and (not (hurd-target?)) + (operating-system-initrd-file os))) (store (operating-system-store-file-system os)) (bootloader (bootloader-configuration-bootloader (operating-system-bootloader os))) (bootloader-name (bootloader-name bootloader)) - (label (operating-system-label os))) + (label (operating-system-label os)) + (multiboot-modules (operating-system-multiboot-modules os))) (boot-parameters (label label) (root-device root-device) @@ -1151,6 +1204,7 @@ such as '--root' and '--load' to <boot-parameters>." (operating-system-kernel-arguments os root-device) (operating-system-user-kernel-arguments os))) (initrd initrd) + (multiboot-modules multiboot-modules) (bootloader-name bootloader-name) (bootloader-menu-entries (bootloader-configuration-menu-entries (operating-system-bootloader os))) -- 2.26.2
* gnu/bootloader/grub.scm (grub-configuration-file): Add support for multiboot. --- gnu/bootloader.scm | 3 +- gnu/bootloader/grub.scm | 71 +++++++++++++++++++++++++---------------- 2 files changed, 46 insertions(+), 28 deletions(-) diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm index 2eebb8e9d9..d0bcab1a06 100644 --- a/gnu/bootloader.scm +++ b/gnu/bootloader.scm @@ -26,7 +26,8 @@ #:use-module (guix ui) #:use-module (srfi srfi-1) #:use-module (ice-9 match) - #:export (menu-entry + #:export (<menu-entry> + menu-entry menu-entry? menu-entry-label menu-entry-device diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index 2d9a39afc3..3e95fece1c 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -25,12 +25,16 @@ #:use-module (guix records) #:use-module ((guix utils) #:select (%current-system)) #:use-module (guix gexp) + #:use-module (guix utils) #:use-module (gnu artwork) #:use-module (gnu bootloader) #:use-module (gnu system uuid) #:use-module (gnu system file-systems) #:use-module (gnu system keyboard) + #:use-module (gnu packages base) #:use-module (gnu packages bootloaders) + #:use-module (gnu packages cross-base) + #:use-module (gnu packages hurd) #:autoload (gnu packages gtk) (guile-cairo guile-rsvg) #:autoload (gnu packages xorg) (xkeyboard-config) #:use-module (ice-9 match) @@ -330,36 +334,49 @@ when booting a root file system on a Btrfs subvolume." (define all-entries (append entries (bootloader-configuration-menu-entries config))) (define (menu-entry->gexp entry) - (let* ((device (menu-entry-device entry)) - (device-mount-point (menu-entry-device-mount-point entry)) - (label (menu-entry-label entry)) - (arguments (menu-entry-linux-arguments entry)) - (kernel (normalize-file (menu-entry-linux entry) - device-mount-point - store-directory-prefix)) - (initrd (normalize-file (menu-entry-initrd entry) - device-mount-point - store-directory-prefix))) - ;; Here DEVICE is the store and DEVICE-MOUNT-POINT is its mount point. - ;; Use the right file names for KERNEL and INITRD in case - ;; DEVICE-MOUNT-POINT is not "/", meaning that the store is on a - ;; separate partition. - #~(format port "menuentry ~s { + (match entry + (($ <menu-entry> label device mount-point linux arguments initrd #f ()) + (let ((linux (normalize-file linux mount-point + store-directory-prefix)) + (initrd (normalize-file initrd mount-point + store-directory-prefix))) + ;; Here DEVICE is the store and DEVICE-MOUNT-POINT is its mount point. + ;; Use the right file names for LINUX and INITRD in case + ;; DEVICE-MOUNT-POINT is not "/", meaning that the store is on a + ;; separate partition. + + ;; When BTRFS-SUBVOLUME-FILE-NAME is defined, prepend it the linux and + ;; initrd paths, to allow booting from a Btrfs subvolume. + #~(format port "menuentry ~s { ~a linux ~a ~a initrd ~a }~%" - #$label - #$(grub-root-search device kernel) - #$kernel (string-join (list #$@arguments)) - #$initrd))) - (define sugar - (eye-candy config - (menu-entry-device (first all-entries)) - (menu-entry-device-mount-point (first all-entries)) - #:store-directory-prefix store-directory-prefix - #:system system - #:port #~port)) + #$label + #$(grub-root-search device linux) + #$linux (string-join (list #$@arguments)) + #$initrd))) + (($ <menu-entry> label device mount-point #f () #f kernel arguments modules) + (let* ((target (%current-target-system))) + #~(format port " +menuentry ~s { + multiboot ~a root=device:hd0s1~a~a +}~%" + #$label + #$kernel (string-join (list #$@arguments) " " 'prefix) + (string-join (map string-join '#$modules) + "\n module " 'prefix)))))) + + (define (sugar) + (let* ((entry (first all-entries)) + (device (menu-entry-device entry)) + (mount-point (menu-entry-device-mount-point entry))) + (eye-candy config + device + mount-point + #:store-directory-prefix store-directory-prefix + #:system system + #:port #~port))) (define keyboard-layout-config (let* ((layout (bootloader-configuration-keyboard-layout config)) @@ -384,7 +401,7 @@ keymap ~a~%" #$keymap)))) "# This file was generated from your Guix configuration. Any changes # will be lost upon reconfiguration. ") - #$sugar + #$(sugar) #$keyboard-layout-config (format port " set default=~a -- 2.26.2
* gnu/system.scm (kernel->boot-label): Add keyword parameter 'hurd'. If set, use it for label. (operating-system-default-label): Call with it with operating-system-hurd. --- gnu/system.scm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gnu/system.scm b/gnu/system.scm index a96a6e6f2c..b814181c69 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -1098,9 +1098,13 @@ listed in OS. The C library expects to find it under (locale-directory definitions #:libcs (operating-system-locale-libcs os))) -(define (kernel->boot-label kernel) +(define* (kernel->boot-label kernel #:key hurd) "Return a label for the bootloader menu entry that boots KERNEL." - (cond ((package? kernel) + (cond ((package? hurd) + (string-append "GNU with the " + (string-titlecase (package-name hurd)) " " + (package-version hurd))) + ((package? kernel) (string-append "GNU with " (string-titlecase (package-name kernel)) " " (package-version kernel))) @@ -1113,7 +1117,8 @@ listed in OS. The C library expects to find it under (define (operating-system-default-label os) "Return the default label for OS, as it will appear in the bootloader menu entry." - (kernel->boot-label (operating-system-kernel os))) + (kernel->boot-label (operating-system-kernel os) + #:hurd (operating-system-hurd os))) (define (store-file-system file-systems) "Return the file system object among FILE-SYSTEMS that contains the store." -- 2.26.2
With this, we can now build a VM like so ./pre-inst-env guix system vm-image --target=i586-pc-gnu --no-grafts \ gnu/system/examples/bare-hurd.tmpl it boots, but needs some more setup/services to be really useful. See also: <https://bugs.gnu.org/40839>; wip-disk-image. * gnu/system/hurd.scm (%hurd-default-operating-system): New exported variable. * gnu/system/examples/bare-hurd.tmpl: New file. * Makefile.am (EXAMPLES): Add it. --- Makefile.am | 3 +- gnu/services.scm | 5 ++- gnu/system/examples/bare-hurd.tmpl | 24 ++++++++++++++ gnu/system/hurd.scm | 50 ++++++++++++++++++++++++++++-- 4 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 gnu/system/examples/bare-hurd.tmpl diff --git a/Makefile.am b/Makefile.am index 5b64386b53..d8c519b4af 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,7 +7,7 @@ # Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> # Copyright © 2017 Leo Famulari <leo@famulari.name> # Copyright © 2017 Ricardo Wurmus <rekado@elephly.net> -# Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org> +# Copyright © 2017, 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> # Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net> # Copyright © 2018 Nikita <nikita@n0.is> # Copyright © 2018 Julien Lepiller <julien@lepiller.eu> @@ -346,6 +346,7 @@ AUX_FILES = \ EXAMPLES = \ gnu/system/examples/asus-c201.tmpl \ gnu/system/examples/bare-bones.tmpl \ + gnu/system/examples/bare-hurd.tmpl \ gnu/system/examples/beaglebone-black.tmpl \ gnu/system/examples/desktop.tmpl \ gnu/system/examples/lightweight-desktop.tmpl \ diff --git a/gnu/services.scm b/gnu/services.scm index 2e4648bf78..614956fbab 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com> +;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -29,10 +30,12 @@ #:use-module (guix describe) #:use-module (guix sets) #:use-module (guix ui) - #:use-module ((guix utils) #:select (source-properties->location)) + #:use-module ((guix utils) #:select (source-properties->location + %current-target-system)) #:use-module (guix modules) #:use-module (gnu packages base) #:use-module (gnu packages bash) + #:use-module (gnu packages hurd) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:use-module (srfi srfi-9 gnu) diff --git a/gnu/system/examples/bare-hurd.tmpl b/gnu/system/examples/bare-hurd.tmpl new file mode 100644 index 0000000000..d100bd6dd8 --- /dev/null +++ b/gnu/system/examples/bare-hurd.tmpl @@ -0,0 +1,24 @@ +;; -*-scheme-*- + +;; This is an operating system configuration template +;; for a "bare bones" setup, with no X11 display server. + +(use-modules (gnu) (gnu system hurd) (guix utils)) + +(define %hurd-os + (operating-system + (inherit %hurd-default-operating-system) + (bootloader (bootloader-configuration + (bootloader grub-minimal-bootloader) + (target "/dev/sdX"))) + (file-systems (cons (file-system + (device (file-system-label "my-root")) + (mount-point "/") + (type "ext2")) + %base-file-systems)) + (host-name "guixygnu") + (timezone "GNUrope") + (packages %base-packages/hurd) + (services %base-services/hurd))) + +%hurd-os diff --git a/gnu/system/hurd.scm b/gnu/system/hurd.scm index 3ccf47aa21..472eca82b9 100644 --- a/gnu/system/hurd.scm +++ b/gnu/system/hurd.scm @@ -21,6 +21,7 @@ #:use-module (guix gexp) #:use-module (guix profiles) #:use-module (guix utils) + #:use-module (gnu bootloader) #:use-module (gnu bootloader grub) #:use-module (gnu packages admin) #:use-module (gnu packages base) @@ -31,8 +32,17 @@ #:use-module (gnu packages guile-xyz) #:use-module (gnu packages hurd) #:use-module (gnu packages less) + #:use-module (gnu services) + #:use-module (gnu services base) + #:use-module (gnu services hurd) + #:use-module (gnu services shepherd) + #:use-module (gnu system) + #:use-module (gnu system shadow) #:use-module (gnu system vm) - #:export (cross-hurd-image)) + #:export (cross-hurd-image + %base-packages/hurd + %base-services/hurd + %hurd-default-operating-system)) ;;; Commentary: ;;; @@ -44,7 +54,43 @@ (define %base-packages/hurd (list hurd bash coreutils file findutils grep sed guile-3.0 guile-colorized guile-readline - net-base inetutils less which)) + net-base inetutils less shepherd which)) + +(define %base-services/hurd + '()) + +(define %hurd-default-operating-system + (operating-system + (kernel gnumach) + ;; (kernel-loadable-modules '()) + (kernel-arguments '()) + (hurd hurd) + (bootloader (bootloader-configuration + (bootloader grub-minimal-bootloader) + (target "/dev/vda"))) + ;; (label (operating-system-default-label this-operating-system)) + (initrd (lambda _ '())) + (initrd-modules (lambda _ '())) + (firmware '()) + (host-name "guixygnu") + ;; (hosts-file #F) + ;; (mapped-devices '()) + (file-systems '()) + ;; (swap-devices '()) + (users '()) + ;(groups '()) + (skeletons '()) + ;; (issue %default-issue) + (packages %base-packages/hurd) + (timezone "GNUrope") + ;; (locale "en_US.utf8") + (locale-definitions '()) + ;; (locale-libcs '()) + (name-service-switch #f) + (essential-services (hurd-default-essential-services this-operating-system)) + (pam-services '()) + (setuid-programs '()) + (sudoers-file #f))) (define* (cross-hurd-image #:key (hurd hurd) (gnumach gnumach)) "Return a cross-built GNU/Hurd image." -- 2.26.2
* gnu/services/hurd.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. * doc/guix.texi (Hurd Services): Document it. --- doc/guix.texi | 13 +++++++++ gnu/local.mk | 1 + gnu/services/hurd.scm | 61 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 gnu/services/hurd.scm diff --git a/doc/guix.texi b/doc/guix.texi index 4776eacacd..97bf067074 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -319,7 +319,9 @@ Services * Version Control Services:: Providing remote access to Git repositories. * Game Services:: Game servers. * PAM Mount Service:: Service to mount volumes when logging in. +* Guix Services:: Services relating specifically to Guix. * Linux Services:: Services tied to the Linux kernel. +* Hurd Services:: Services specific to a Hurd System. * Miscellaneous Services:: Other services. Defining Services @@ -12594,6 +12596,7 @@ declaration. * PAM Mount Service:: Service to mount volumes when logging in. * Guix Services:: Services relating specifically to Guix. * Linux Services:: Services tied to the Linux kernel. +* Hurd Services:: Services specific for a Hurd System. * Miscellaneous Services:: Other services. @end menu @@ -26032,6 +26035,16 @@ parameters, can be done as follow: @end lisp @end deffn +@node Hurd Services +@subsection Hurd Services + +@deffn {Scheme Procedure} hurd-etc-service @var{os} +This service implements a minimal @code{etc-service}, adding some +specifics for the Hurd. + +It is part of the @code{hurd-default-essential-services}. +@end deffn + @node Miscellaneous Services @subsection Miscellaneous Services diff --git a/gnu/local.mk b/gnu/local.mk index 8abca8659e..d1d086abe0 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -582,6 +582,7 @@ GNU_SYSTEM_MODULES = \ %D%/services/games.scm \ %D%/services/getmail.scm \ %D%/services/guix.scm \ + %D%/services/hurd.scm \ %D%/services/kerberos.scm \ %D%/services/linux.scm \ %D%/services/lirc.scm \ diff --git a/gnu/services/hurd.scm b/gnu/services/hurd.scm new file mode 100644 index 0000000000..6e57b22810 --- /dev/null +++ b/gnu/services/hurd.scm @@ -0,0 +1,61 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. + +(define-module (gnu services hurd) + #:use-module (gnu packages admin) + #:use-module (gnu services) + #:use-module (gnu system) + #:use-module (guix gexp) + #:use-module (guix records) + #:export (hurd-etc-service)) + +;;; Commentary: +;;; +;;; This module implements services for the Hurd. +;;; +;;; Code: + +\f +;;; +;;; The ETC service for the Hurd. +;;; + +(define (hurd-etc-service os) + "Return a <service> that builds containing the static part of the /etc +directory." + (let ((profile (mixed-text-file "profile" "\ +# Generated by hurd-etc-services +export PS1='\\u@\\h\\$ ' + +GUIX_PROFILE=\"/run/current-system/profile\" +. \"$GUIX_PROFILE/etc/profile\" + +GUIX_PROFILE=\"$HOME/.guix-profile\" +if [ -f \"$GUIX_PROFILE/etc/profile\" ]; then + . \"$GUIX_PROFILE/etc/profile\" +fi\n")) + (hurd (operating-system-hurd os))) + (etc-service + `(("services" ,(file-append net-base "/etc/services")) + ("protocols" ,(file-append net-base "/etc/protocols")) + ("profile" ,profile) + ("hostname" ,(plain-file "hostname" (operating-system-host-name os))) + ("login" ,(file-append hurd "/etc/login")) + ("motd" ,(file-append hurd "/etc/motd")))))) + +;;; hurd.scm ends here -- 2.26.2
* gnu/build/activation.scm (boot-time-system): Add #:kernel-command-line parameter. * gnu/build/activation.scm (activate-current-system): Likewise, and pass it. Change optional system parameter to #:system. * gnu/system.scm (gnu/linux-activation-script): Rename from activation-script. (activation-script, hurd-activation-script): New procedure. --- gnu/build/activation.scm | 9 +++-- gnu/services.scm | 81 +++++++++++++++++++++++++++------------- 2 files changed, 60 insertions(+), 30 deletions(-) diff --git a/gnu/build/activation.scm b/gnu/build/activation.scm index 30f5e87d5a..85ff8d8996 100644 --- a/gnu/build/activation.scm +++ b/gnu/build/activation.scm @@ -318,13 +318,14 @@ improvement." ;; a new system configuration and activate it, without rebooting. "/run/current-system") -(define (boot-time-system) +(define* (boot-time-system #:key (kernel-command-line linux-command-line)) "Return the '--system' argument passed on the kernel command line." - (find-long-option "--system" (linux-command-line))) + (find-long-option "--system" (kernel-command-line))) (define* (activate-current-system - #:optional (system (or (getenv "GUIX_NEW_SYSTEM") - (boot-time-system)))) + #:key (kernel-command-line linux-command-line) + (system (or (getenv "GUIX_NEW_SYSTEM") + (boot-time-system #:kernel-command-line kernel-command-line)))) "Atomically make SYSTEM the current system." ;; The 'GUIX_NEW_SYSTEM' environment variable is used as a way for 'guix ;; system reconfigure' to pass the file name of the new system. diff --git a/gnu/services.scm b/gnu/services.scm index 614956fbab..78f5d15f06 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -519,35 +519,64 @@ ACTIVATION-SCRIPT-TYPE." (define (activation-script gexps) "Return the system's activation script, which evaluates GEXPS." + (program-file "activate.scm" (if (hurd-target?) + (hurd-activation-script gexps) + (gnu/linux-activation-script gexps)))) + +(define (gnu/linux-activation-script gexps) + "Return a GNU/Linux system activation script, which evaluates GEXPS." + (define actions (map (cut program-file "activate-service.scm" <>) gexps)) - (program-file "activate.scm" - (with-imported-modules (source-module-closure - '((gnu build activation) - (guix build utils))) - #~(begin - (use-modules (gnu build activation) - (guix build utils)) - - ;; Make sure the user accounting database exists. If it - ;; does not exist, 'setutxent' does not create it and - ;; thus there is no accounting at all. - (close-port (open-file "/var/run/utmpx" "a0")) - - ;; Same for 'wtmp', which is populated by mingetty et - ;; al. - (mkdir-p "/var/log") - (close-port (open-file "/var/log/wtmp" "a0")) - - ;; Set up /run/current-system. Among other things this - ;; sets up locales, which the activation snippets - ;; executed below may expect. - (activate-current-system) - - ;; Run the services' activation snippets. - ;; TODO: Use 'load-compiled'. - (for-each primitive-load '#$actions))))) + (with-imported-modules (source-module-closure + '((gnu build activation) + (guix build utils))) + #~(begin + (use-modules (gnu build activation) + (guix build utils)) + + ;; Make sure the user accounting database exists. If it + ;; does not exist, 'setutxent' does not create it and + ;; thus there is no accounting at all. + (close-port (open-file "/var/run/utmpx" "a0")) + + ;; Same for 'wtmp', which is populated by mingetty et + ;; al. + (close-port (open-file "/var/log/wtmp" "a0")) + + ;; Set up /run/current-system. Among other things this + ;; sets up locales, which the activation snippets + ;; executed below may expect. + (activate-current-system) + + ;; Run the services' activation snippets. + ;; TODO: Use 'load-compiled'. + (for-each primitive-load '#$actions)))) + +(define (hurd-activation-script gexps) + "Return the Hurd activation script, which evaluates GEXPS." + (define actions + (map (cut program-file "activate-service.scm" <>) gexps)) + + (with-imported-modules (source-module-closure + '((gnu build activation) + (guix build utils))) + #~(begin + (use-modules (gnu build activation) + (guix build utils)) + + (mkdir-p "/var/run") ;for the PID files + (mkdir-p "/var/log") + + ;; Set up /run/current-system. Among other things this + ;; sets up locales, which the activation snippets + ;; executed below may expect. + (activate-current-system #:kernel-command-line command-line) + + ;; Run the services' activation snippets. + ;; TODO: Use 'load-compiled'. + (for-each primitive-load '#$actions)))) (define (gexps->activation-gexp gexps) "Return a gexp that runs the activation script containing GEXPS." -- 2.26.2
Hi, Jan Nieuwenhuizen <janneke@gnu.org> skribis: > So, after digesting your message here I took the next step: grep for > _HURD_STARTUP and change it there, like so > > diff --git a/gnu/packages/hurd.scm b/gnu/packages/hurd.scm > index 421783eb80..8c73ea8430 100644 > --- a/gnu/packages/hurd.scm > +++ b/gnu/packages/hurd.scm > @@ -428,9 +428,10 @@ exec ${system}/rc \"$@\" > "startup/startup.c") > (("/hurd/") > (string-append out "/hurd/"))) > - (substitute* "hurd/paths.h" > - (("_HURD_STARTUP\t") > - (string-append "_HURD_STARTUP\t\"" out "\" "))) > + (substitute* '("libdiskfs/boot-start.c" > + "libdiskfs/opts-std-startup.c") > + (("_HURD_STARTUP") > + (string-append "\"" out "/hurd/startup\""))) Perfect! Perhaps we can add a comment explaining that this is needed for the first boot, when the /hurd symlink doesn’t exist yet. > This also works, and so I figure we're fine now. I'm resetting > wip-hurd-vm and, like Mathieu suggested will prepare to send send a > patch series here for the unreviewed subset of patches. Thank you! Ludo’.
Ludovic Courtès writes: > Jan Nieuwenhuizen <janneke@gnu.org> skribis: > >> So, after digesting your message here I took the next step: grep for >> _HURD_STARTUP and change it there, like so >> >> diff --git a/gnu/packages/hurd.scm b/gnu/packages/hurd.scm >> index 421783eb80..8c73ea8430 100644 >> --- a/gnu/packages/hurd.scm >> +++ b/gnu/packages/hurd.scm >> @@ -428,9 +428,10 @@ exec ${system}/rc \"$@\" >> "startup/startup.c") >> (("/hurd/") >> (string-append out "/hurd/"))) >> - (substitute* "hurd/paths.h" >> - (("_HURD_STARTUP\t") >> - (string-append "_HURD_STARTUP\t\"" out "\" "))) >> + (substitute* '("libdiskfs/boot-start.c" >> + "libdiskfs/opts-std-startup.c") >> + (("_HURD_STARTUP") >> + (string-append "\"" out "/hurd/startup\""))) > > Perfect! Perhaps we can add a comment explaining that this is needed > for the first boot, when the /hurd symlink doesn’t exist yet. That's a good idea. I've added a squash commit with ;; Upon first boot the /hurd symlink does not exist; it is ;; created during activation: Hard-code the .../hurd store file ;; name. >> This also works, and so I figure we're fine now. I'm resetting >> wip-hurd-vm and, like Mathieu suggested will prepare to send send a >> patch series here for the unreviewed subset of patches. > > Thank you! In other news, I've been playing with at "devel-hurd.tmpl" system and just succeeded to build gnu-make-boot0! I still need sort of a hack to include %bootstrap-gcc etc, but this gives me good hopes that we'll be able create a functional VM to build substitutes after merging! Greetings, Janneke -- Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
Hey Jan, > +Using GNU@tie{}mach in combination with a @code{hurd} is experimental > +and only available when building a vm-image.}. Maybe replace "vm-image" by "virtual machine disk image"? > + > +@cindex hurd > +@item @code{hurd} (default: @code{#f}) > +The hurd to be started by the kernel. This is required to build an > +experimental vm-image for the Hurd and requires using @code{kernel} Ditto. Thanks, Mathieu
> + (mach (if (%current-target-system) > + ;; A cross-built GNUmach does not work > + (with-parameters ((%current-system "i686-linux") > + (%current-target-system #f)) > + mach) Maybe it would make more sense to check if we are on a Hurd system, rather than just checking for %current-target-system to be set, don't know. > + (libc (if target > + (with-parameters ((%current-target-system #f)) > + (cross-libc target)) > + glibc)) In the future, it would be nice to make this think transparent. Anyway, for now this is the best we can do I think. Thanks, Mathieu
> + (($ <menu-entry> label device mount-point #f () #f kernel arguments modules) > + (let* ((target (%current-target-system))) This doesn't seem to be used anymore. Plus using %current-target-system here could not give the expected result. I think that the only two "safe" ways are to use (current-target-system) from a monadic context, or to use "let-system". We should maybe write something about that in the documentation. > + #~(format port " > +menuentry ~s { > + multiboot ~a root=device:hd0s1~a~a > +}~%" If we add support for EFI one day, then it could be "hd0s2". In "install-grub-disk-image", I manage to get to root-index from the caller. I think it will be harder to do the same thing here. It's ok for me if we leave it this way. Thanks, Mathieu
> ./pre-inst-env guix system vm-image --target=i586-pc-gnu --no-grafts \ > gnu/system/examples/bare-hurd.tmpl Not related to your serie, but I would really like the "image" catalog I proposed to help here. Most people struggle to get the difference between --system and --target. Plus, those cross-compilation targets are not really documented. I think if one could write: guix system image gnu/system/images/bare-hurd.scm or so, it would help. But this needs some more discussions. > - #:use-module ((guix utils) #:select (source-properties->location)) > + #:use-module ((guix utils) #:select (source-properties->location > + %current-target-system)) You're not using it right? > + ;; (kernel-loadable-modules '()) Remove it. > + ;; (label (operating-system-default-label this-operating-system)) Same for this one and the other commented lines below. Thanks, Mathieu
> (define (activation-script gexps)
> "Return the system's activation script, which evaluates GEXPS."
> + (program-file "activate.scm" (if (hurd-target?)
> + (hurd-activation-script gexps)
> + (gnu/linux-activation-script gexps))))
"hurd-target?" is using %current-target-system. It would be safer to use
let-system here I guess.
I think Ludo will have some more comments, but let me say again that you
are doing a great job here, many thanks!
Mathieu
Mathieu Othacehe writes: > Hey Jan, > >> +Using GNU@tie{}mach in combination with a @code{hurd} is experimental >> +and only available when building a vm-image.}. > > Maybe replace "vm-image" by "virtual machine disk image"? Okay. >> + >> +@cindex hurd >> +@item @code{hurd} (default: @code{#f}) >> +The hurd to be started by the kernel. This is required to build an >> +experimental vm-image for the Hurd and requires using @code{kernel} > > Ditto. Done. Thanks, Janneke -- Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
Mathieu Othacehe writes: >> + (($ <menu-entry> label device mount-point #f () #f kernel arguments modules) >> + (let* ((target (%current-target-system))) > > This doesn't seem to be used anymore. Oops, but yeah: great! Sorry -- this went through so many iterations, thanks for catching it. > Plus using %current-target-system > here could not give the expected result. I think that the only two > "safe" ways are to use (current-target-system) from a monadic context, > or to use "let-system". > We should maybe write something about that in the documentation. Maybe...I think also that I should become more aware about monadic context and its implications. >> + #~(format port " >> +menuentry ~s { >> + multiboot ~a root=device:hd0s1~a~a >> +}~%" > > If we add support for EFI one day, then it could be "hd0s2". In > "install-grub-disk-image", I manage to get to root-index from the > caller. I think it will be harder to do the same thing here. It's ok for > me if we leave it this way. Of course -- and this only works as long as we are only building virtual machine images. Changed to this (let ((root-index 1)) ; XXX EFI will need root-index 2 Thanks, Janneke -- Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
Mathieu Othacehe writes: Hello Mathieu, >> (define (activation-script gexps) >> "Return the system's activation script, which evaluates GEXPS." >> + (program-file "activate.scm" (if (hurd-target?) >> + (hurd-activation-script gexps) >> + (gnu/linux-activation-script gexps)))) > > "hurd-target?" is using %current-target-system. It would be safer to use > let-system here I guess. Okay, changed to (let-system (system target) (program-file "activate.scm" (if (hurd-triplet? (or target system)) (hurd-activation-script gexps) (gnu/linux-activation-script gexps))))) > I think Ludo will have some more comments, but let me say again that you > are doing a great job here, many thanks! Thank you! -- luckily I get some help ;) Janneke -- Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
Mathieu Othacehe writes: Hello! >> + (mach (if (%current-target-system) >> + ;; A cross-built GNUmach does not work >> + (with-parameters ((%current-system "i686-linux") >> + (%current-target-system #f)) >> + mach) > > Maybe it would make more sense to check if we are on a Hurd system, > rather than just checking for %current-target-system to be set, don't > know. Ah yes. When this IF runs we already checked that we are building a hurd system; this adds two lines leading up to the above snippet (if (operating-system-hurd os) (let* ((mach (operating-system-kernel os)) (mach (if (%current-target-system) ...but that means that this last IF is maybe unnecessarily implicit and only really makes sense by adding/remembering that context. Changed it to (mach (if (and=> (%current-target-system) hurd-triplet?) I guess that's friendlier? >> + (libc (if target >> + (with-parameters ((%current-target-system #f)) >> + (cross-libc target)) >> + glibc)) > > In the future, it would be nice to make this think transparent. Anyway, > for now this is the best we can do I think. Yes, I've added a comment ;; TODO: cross-libc has extra patches for the Hurd; ;; remove in next rebuild cycle (cross-libc target)) I have now 8 squash! commits; I'll be resetting wip-hurd-vm just once more before merging, after checking in with Ludovic and re-running some tests. Really looking forward to seeing a Guix Hurd VM hookup-up in bayfront and really start building a Hurd system, mabye we'll see some more people join in. I think that should be (almost?) possible after merging, right? Greetings, Janneke -- Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com