merge wip-hurd-vm

  • Done
  • quality assurance status badge
Details
3 participants
  • Jan Nieuwenhuizen
  • Ludovic Courtès
  • Mathieu Othacehe
Owner
unassigned
Submitted by
Jan Nieuwenhuizen
Severity
normal
J
J
Jan Nieuwenhuizen wrote on 26 May 2020 16:21
(address . bug-guix@gnu.org)
87o8qavktf.fsf@gnu.org
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

Toggle snippet (3 lines)
./pre-inst-env guix build -f gnu/system/hurd.scm

=> /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

Toggle snippet (3 lines)
./pre-inst-env guix system vm-image --no-grafts --target=i586-pc-gnu gnu/system/examples/bare-hurd.tmpl

=> /gnu/store/8pr6qnwl4b5kria0j0hxscv66izc8zpi-qemu-image


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

Toggle snippet (3 lines)
./pre-inst-env guix system disk-image --no-grafts --target=i586-pc-gnu gnu/system/examples/bare-hurd.tmpl

=> /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

Toggle snippet (3 lines)
b605a36031 * origin/wip-hurd-vm WIP hurd-directives

and we also already had a small brain storming on IRC about

Toggle snippet (5 lines)
dd62341283 * bootloader: grub: Add support for '<hurd-menu-entry>'.
ec1dfae81b * system: Add 'hurd' field to <boot-parameters>.
43df8616f6 * bootloader: Add `<hurd-menu-entry>'.

I guess that before merging, we will want to rewrite this bit, alongside
these lines, nicely summarized as

Toggle snippet (9 lines)
<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

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
M
M
Mathieu Othacehe wrote on 27 May 2020 12:01
(name . Jan Nieuwenhuizen)(address . janneke@gnu.org)(address . 41541@debbugs.gnu.org)
87tv01vgqy.fsf@gnu.org
Hello Jan,

That's a good summary of the (complex) situation, thank you!

Toggle quote (4 lines)
> 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
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(-)

Toggle diff (67 lines)
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
J
J
Jan Nieuwenhuizen wrote on 27 May 2020 13:11
(name . Mathieu Othacehe)(address . othacehe@gnu.org)(address . 41541@debbugs.gnu.org)
87pnap7hv3.fsf@gnu.org
Mathieu Othacehe writes:

Hello Mathieu,

Toggle quote (2 lines)
> That's a good summary of the (complex) situation, thank you!

Yeah...well sorry for helping create such a mess :-)

Toggle quote (7 lines)
>> 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!

Toggle quote (6 lines)
> 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 :-)

Toggle diff (79 lines)
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
J
J
Jan Nieuwenhuizen wrote on 30 May 2020 16:40
(name . Mathieu Othacehe)(address . othacehe@gnu.org)(address . 41541@debbugs.gnu.org)
87blm54hae.fsf@gnu.org
Mathieu Othacehe writes:

Hello!

Toggle quote (9 lines)
> 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
M
M
Mathieu Othacehe wrote on 2 Jun 2020 10:48
(name . Jan Nieuwenhuizen)(address . janneke@gnu.org)(address . 41541@debbugs.gnu.org)
874krtyhtg.fsf@gnu.org
Hello Jan,

Toggle quote (4 lines)
> 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
J
J
Jan Nieuwenhuizen wrote on 2 Jun 2020 11:24
(name . Mathieu Othacehe)(address . othacehe@gnu.org)(address . 41541@debbugs.gnu.org)
87h7vtzupa.fsf@gnu.org
Mathieu Othacehe writes:

Hello Mathieu,

Toggle quote (6 lines)
>> 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

Toggle snippet (19 lines)
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"))

later moving it to hurd-boot, and its subsequent removal...

Toggle quote (3 lines)
> 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
M
M
Mathieu Othacehe wrote on 2 Jun 2020 12:16
(name . Jan Nieuwenhuizen)(address . janneke@gnu.org)(address . 41541@debbugs.gnu.org)
87r1uxwz5q.fsf@gnu.org
Toggle quote (9 lines)
> 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
J
J
Jan Nieuwenhuizen wrote on 2 Jun 2020 14:23
(name . Mathieu Othacehe)(address . othacehe@gnu.org)(address . 41541@debbugs.gnu.org)
87mu5ly7tx.fsf@gnu.org
Mathieu Othacehe writes:

Hi Mathieu,

Toggle quote (9 lines)
> 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!

Toggle quote (4 lines)
> 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
--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com| Avatar® http://AvatarAcademy.com
L
L
Ludovic Courtès wrote on 2 Jun 2020 14:40
(name . Jan Nieuwenhuizen)(address . janneke@gnu.org)
87mu5lsksn.fsf@gnu.org
Hi,

Jan Nieuwenhuizen <janneke@gnu.org> skribis:

Toggle quote (15 lines)
>> 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).

Toggle quote (6 lines)
>> 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.

Toggle quote (17 lines)
>>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.

[…]

Toggle quote (9 lines)
> +;; 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.

Toggle quote (17 lines)
> +(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)))))

Toggle quote (13 lines)
> + (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. :-)
J
J
Jan Nieuwenhuizen wrote on 2 Jun 2020 15:39
(name . Ludovic Courtès)(address . ludo@gnu.org)
87y2p5vb7v.fsf@gnu.org
Ludovic Courtès writes:

Hello!

Toggle quote (28 lines)
> 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.

Toggle quote (20 lines)
>>> 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.

Toggle quote (9 lines)
>> +(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!

Toggle quote (19 lines)
>> +(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)

Toggle quote (11 lines)
> (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!

Toggle quote (16 lines)
>> + (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!

Toggle quote (2 lines)
> 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
--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com| Avatar® http://AvatarAcademy.com
L
L
Ludovic Courtès wrote on 3 Jun 2020 11:18
(name . Jan Nieuwenhuizen)(address . janneke@gnu.org)
87wo4oqzgu.fsf@gnu.org
Hi,

Jan Nieuwenhuizen <janneke@gnu.org> skribis:

Toggle quote (17 lines)
> 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’.
J
J
Jan Nieuwenhuizen wrote on 3 Jun 2020 17:22
(name . Ludovic Courtès)(address . ludo@gnu.org)
87k10otbr1.fsf@gnu.org
Ludovic Courtès writes:

Toggle quote (19 lines)
>> 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
M
M
Mathieu Othacehe wrote on 3 Jun 2020 17:38
(name . Jan Nieuwenhuizen)(address . janneke@gnu.org)
87v9k85fdc.fsf@gnu.org
Hey!

Toggle quote (11 lines)
> 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 :)

Toggle quote (2 lines)
> ! 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.

Toggle quote (11 lines)
> 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
J
J
Jan Nieuwenhuizen wrote on 3 Jun 2020 22:27
(name . Mathieu Othacehe)(address . othacehe@gnu.org)
874krrrj3c.fsf@gnu.org
Mathieu Othacehe writes:

Hi!

Toggle quote (18 lines)
>> 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

Toggle snippet (105 lines)
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=.*")

produces a bootable VM. So...this could be great or maybe...well, what
do you think?

Toggle quote (15 lines)
>> 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
L
L
Ludovic Courtès wrote on 4 Jun 2020 11:32
(name . Jan Nieuwenhuizen)(address . janneke@gnu.org)
87mu5jfa75.fsf@gnu.org
Hi!

Jan Nieuwenhuizen <janneke@gnu.org> skribis:

Toggle quote (35 lines)
> --- 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’.
J
J
Jan Nieuwenhuizen wrote on 4 Jun 2020 13:33
(name . Ludovic Courtès)(address . ludo@gnu.org)
87mu5jhxp8.fsf@gnu.org
Ludovic Courtès writes:

Hello!

Toggle quote (5 lines)
> Jan Nieuwenhuizen <janneke@gnu.org> skribis:
>
>> --- a/gnu/packages/hurd.scm
>> +++ b/gnu/packages/hurd.scm

[...]

Toggle quote (17 lines)
>> + (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!

Toggle quote (9 lines)
> 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

Toggle diff (26 lines)
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
J
J
Jan (janneke) Nieuwenhuizen wrote on 4 Jun 2020 15:59
[PATCH 1/8] system: Add 'hurd' field to <operating-system>.
(address . 41541@debbugs.gnu.org)
20200604135914.4499-2-janneke@gnu.org
* 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(-)

Toggle diff (47 lines)
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
J
J
Jan (janneke) Nieuwenhuizen wrote on 4 Jun 2020 15:59
[PATCH 2/8] bootloader: Extend `<menu-entry>' for multiboot.
(address . 41541@debbugs.gnu.org)
20200604135914.4499-3-janneke@gnu.org
* 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(-)

Toggle diff (92 lines)
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)))))
;;;
--
2.26.2
J
J
Jan (janneke) Nieuwenhuizen wrote on 4 Jun 2020 15:59
[PATCH 0/9] Merge wip-hurd-vm "last review round"
(address . 41541@debbugs.gnu.org)(name . Jan Nieuwenhuizen)(address . janneke@gnu.org)
20200604135914.4499-1-janneke@gnu.org
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
J
J
Jan (janneke) Nieuwenhuizen wrote on 4 Jun 2020 15:59
[PATCH 3/8] system: Add 'multiboot-modules' field to <boot-parameters>.
(address . 41541@debbugs.gnu.org)
20200604135914.4499-4-janneke@gnu.org
* 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(-)

Toggle diff (181 lines)
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)
+ '())))))
;;;
@@ -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
J
J
Jan (janneke) Nieuwenhuizen wrote on 4 Jun 2020 15:59
[PATCH 4/8] bootloader: grub: Add support for multiboot.
(address . 41541@debbugs.gnu.org)
20200604135914.4499-5-janneke@gnu.org
* 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(-)

Toggle diff (122 lines)
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
J
J
Jan (janneke) Nieuwenhuizen wrote on 4 Jun 2020 15:59
[PATCH 5/8] system: Use 'hurd' package in label.
(address . 41541@debbugs.gnu.org)
20200604135914.4499-6-janneke@gnu.org
* 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(-)

Toggle diff (32 lines)
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
J
J
Jan (janneke) Nieuwenhuizen wrote on 4 Jun 2020 15:59
[PATCH 6/8] system: examples: Add bare-hurd.tmpl.
(address . 41541@debbugs.gnu.org)
20200604135914.4499-7-janneke@gnu.org
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

Toggle diff (155 lines)
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
J
J
Jan (janneke) Nieuwenhuizen wrote on 4 Jun 2020 15:59
[PATCH 8/8] system: Add `hurd-activation'.
(address . 41541@debbugs.gnu.org)
20200604135914.4499-9-janneke@gnu.org
* 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(-)

Toggle diff (120 lines)
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
J
J
Jan (janneke) Nieuwenhuizen wrote on 4 Jun 2020 15:59
[PATCH 7/8] services: hurd: Add `hurd-etc-service'.
(address . 41541@debbugs.gnu.org)
20200604135914.4499-8-janneke@gnu.org
* 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

Toggle diff (120 lines)
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:
+
+
+;;;
+;;; 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
L
L
Ludovic Courtès wrote on 5 Jun 2020 18:08
Re: bug#41541: merge wip-hurd-vm
(name . Jan Nieuwenhuizen)(address . janneke@gnu.org)
878sh14hsv.fsf@gnu.org
Hi,

Jan Nieuwenhuizen <janneke@gnu.org> skribis:

Toggle quote (19 lines)
> 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.

Toggle quote (4 lines)
> 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’.
J
J
Jan Nieuwenhuizen wrote on 5 Jun 2020 18:24
(name . Ludovic Courtès)(address . ludo@gnu.org)
87a71ha3ay.fsf@gnu.org
Ludovic Courtès writes:

Toggle quote (24 lines)
> 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.

Toggle quote (6 lines)
>> 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
M
M
Mathieu Othacehe wrote on 6 Jun 2020 09:21
Re: bug#41541: [PATCH 1/8] system: Add 'hurd' field to <operating-system>.
(name . Jan (janneke) Nieuwenhuizen)(address . janneke@gnu.org)(address . 41541@debbugs.gnu.org)
87img4mzh7.fsf@gnu.org
Hey Jan,

Toggle quote (3 lines)
> +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"?
Toggle quote (6 lines)
> +
> +@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
M
M
Mathieu Othacehe wrote on 6 Jun 2020 09:32
Re: bug#41541: [PATCH 3/8] system: Add 'multiboot-modules' field to <boot-parameters>.
(name . Jan (janneke) Nieuwenhuizen)(address . janneke@gnu.org)(address . 41541@debbugs.gnu.org)
87eeqsmyxy.fsf@gnu.org
Toggle quote (6 lines)
> + (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.

Toggle quote (5 lines)
> + (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
M
M
Mathieu Othacehe wrote on 6 Jun 2020 09:47
Re: bug#41541: [PATCH 4/8] bootloader: grub: Add support for multiboot.
(name . Jan (janneke) Nieuwenhuizen)(address . janneke@gnu.org)(address . 41541@debbugs.gnu.org)
87a71gmy9u.fsf@gnu.org
Toggle quote (3 lines)
> + (($ <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.

Toggle quote (5 lines)
> + #~(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
M
M
Mathieu Othacehe wrote on 6 Jun 2020 09:56
Re: bug#41541: [PATCH 6/8] system: examples: Add bare-hurd.tmpl.
(name . Jan (janneke) Nieuwenhuizen)(address . janneke@gnu.org)(address . 41541@debbugs.gnu.org)
875zc4mxtu.fsf@gnu.org
Toggle quote (3 lines)
> ./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.

Toggle quote (4 lines)
> - #: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?

Toggle quote (2 lines)
> + ;; (kernel-loadable-modules '())

Remove it.

Toggle quote (2 lines)
> + ;; (label (operating-system-default-label this-operating-system))

Same for this one and the other commented lines below.

Thanks,

Mathieu
M
M
Mathieu Othacehe wrote on 6 Jun 2020 10:03
Re: bug#41541: [PATCH 8/8] system: Add `hurd-activation'.
(name . Jan (janneke) Nieuwenhuizen)(address . janneke@gnu.org)(address . 41541@debbugs.gnu.org)
871rmsmxiz.fsf@gnu.org
Toggle quote (6 lines)
> (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
J
J
Jan Nieuwenhuizen wrote on 6 Jun 2020 10:26
Re: bug#41541: [PATCH 1/8] system: Add 'hurd' field to <operating-system>.
(name . Mathieu Othacehe)(address . othacehe@gnu.org)(address . 41541@debbugs.gnu.org)
87r1us7g7t.fsf@gnu.org
Mathieu Othacehe writes:

Toggle quote (7 lines)
> 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.

Toggle quote (8 lines)
>> +
>> +@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
J
J
Jan Nieuwenhuizen wrote on 6 Jun 2020 10:46
Re: bug#41541: [PATCH 4/8] bootloader: grub: Add support for multiboot.
(name . Mathieu Othacehe)(address . othacehe@gnu.org)(address . 41541@debbugs.gnu.org)
87mu5g7fah.fsf@gnu.org
Mathieu Othacehe writes:

Toggle quote (5 lines)
>> + (($ <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.

Toggle quote (7 lines)
> 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.

Toggle quote (10 lines)
>> + #~(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
J
J
Jan Nieuwenhuizen wrote on 6 Jun 2020 10:54
Re: bug#41541: [PATCH 8/8] system: Add `hurd-activation'.
(name . Mathieu Othacehe)(address . othacehe@gnu.org)(address . 41541@debbugs.gnu.org)
87img47ewh.fsf@gnu.org
Mathieu Othacehe writes:

Hello Mathieu,

Toggle quote (9 lines)
>> (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)))))

Toggle quote (3 lines)
> 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
J
J
Jan Nieuwenhuizen wrote on 6 Jun 2020 12:13
Re: bug#41541: [PATCH 3/8] system: Add 'multiboot-modules' field to <boot-parameters>.
(name . Mathieu Othacehe)(address . othacehe@gnu.org)(address . 41541@debbugs.gnu.org)
87ftb84i3s.fsf@gnu.org
Mathieu Othacehe writes:

Hello!

Toggle quote (10 lines)
>> + (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?

Toggle quote (8 lines)
>> + (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
L
L
Ludovic Courtès wrote on 6 Jun 2020 12:40
control message for bug #41541
(address . control@debbugs.gnu.org)
87y2p0wk82.fsf@gnu.org
reassign 41541 guix-patches
quit
L
L
Ludovic Courtès wrote on 6 Jun 2020 12:45
Re: bug#41541: [PATCH 1/8] system: Add 'hurd' field to <operating-system>.
(name . Jan (janneke) Nieuwenhuizen)(address . janneke@gnu.org)(address . 41541@debbugs.gnu.org)
87r1uswk0c.fsf@gnu.org
Hi!

"Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> skribis:

Toggle quote (22 lines)
> * 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

Using GNU@tie{}Mach with the GNU@tie{}Hurd is experimental

Toggle quote (8 lines)
> +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.

To show that this field is not specific to disk/VM images, how about
something along these lines:

When this field is set, produce a GNU/Hurd operating system. In that
case, @code{kernel} must also be set to the @code{gnumach}
package---the microkernel the Hurd runs on.

@quotation Warning
This feature is experimental and only supported for disk images.
@end quotation

Ludo’.
L
L
Ludovic Courtès wrote on 6 Jun 2020 12:48
Re: bug#41541: [PATCH 2/8] bootloader: Extend `<menu-entry>' for multiboot.
(name . Jan (janneke) Nieuwenhuizen)(address . janneke@gnu.org)(address . 41541@debbugs.gnu.org)
87mu5gwjv2.fsf@gnu.org
"Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> skribis:

Toggle quote (5 lines)
> * 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.

Could you mention the new fields in guix.texi?

Otherwise LGTM!
L
L
Ludovic Courtès wrote on 6 Jun 2020 12:55
Re: bug#41541: [PATCH 3/8] system: Add 'multiboot-modules' field to <boot-parameters>.
(name . Mathieu Othacehe)(address . othacehe@gnu.org)
878sh0wjj3.fsf@gnu.org
Hi,

Mathieu Othacehe <othacehe@gnu.org> skribis:

Toggle quote (10 lines)
>> + (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.

If this hack is still needed, can we move it away to hurd-os.tmpl, or to
the ‘gnumach’ package itself or something?

I think it’s best to keep (gnu system) free of any such assumptions.

Toggle quote (8 lines)
>> + (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.

Yeah, perhaps add a FIXME.

Toggle quote (2 lines)
>> "--x-xattr-translator-records"

Do we need this yet? If it can wait for later, that’s even nicer IMO as
it would allow us to separate concerns.

Ludo’.
L
L
Ludovic Courtès wrote on 6 Jun 2020 12:57
Re: bug#41541: [PATCH 4/8] bootloader: grub: Add support for multiboot.
(name . Jan (janneke) Nieuwenhuizen)(address . janneke@gnu.org)(address . 41541@debbugs.gnu.org)
871rmswjg7.fsf@gnu.org
"Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> skribis:

Toggle quote (3 lines)
> * gnu/bootloader/grub.scm (grub-configuration-file): Add support for
> multiboot.

[...]

Toggle quote (3 lines)
> - #:export (menu-entry
> + #:export (<menu-entry>

Please don’t do that. In general we shouldn’t export record-type
descriptors as it breaks encapsulation.
L
L
Ludovic Courtès wrote on 6 Jun 2020 12:57
Re: bug#41541: [PATCH 5/8] system: Use 'hurd' package in label.
(name . Jan (janneke) Nieuwenhuizen)(address . janneke@gnu.org)(address . 41541@debbugs.gnu.org)
87wo4kv4v1.fsf@gnu.org
"Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> skribis:

Toggle quote (4 lines)
> * 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.

LGTM! :-)
J
J
Jan Nieuwenhuizen wrote on 6 Jun 2020 12:58
Re: bug#41541: [PATCH 6/8] system: examples: Add bare-hurd.tmpl.
(name . Mathieu Othacehe)(address . othacehe@gnu.org)
877dwk4g1m.fsf@gnu.org
Mathieu Othacehe writes:

Hello Mathieu, Ludo!

Toggle quote (14 lines)
>> ./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.

Yes, I agree. Do you propose to hold back merging wip-hurd-vm until
after merging the "image" catalog feature and then rewrite this message?

Exactly when we merge wip-hurd-vm does not matter all that much to me,
it's much more important/interesting to agree when we're happy with it.

Toggle quote (6 lines)
>> - #: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?

Ah, no (not since the grub work moved).

Toggle quote (4 lines)
>> + ;; (kernel-loadable-modules '())
>
> Remove it.

Ok, I was already unsure about keeping...

Toggle quote (4 lines)
>> + ;; (label (operating-system-default-label this-operating-system))
>
> Same for this one and the other commented lines below.

...these all. They were pretty helpful for me to get it to work,
initially. This will see more changes as Hurd support improves!

Hmm, oops: the guix-system.sh test fails. Added this

Toggle snippet (20 lines)
diff --git a/tests/guix-system.sh b/tests/guix-system.sh
index 3a831cba1d..0e22686a34 100644
--- a/tests/guix-system.sh
+++ b/tests/guix-system.sh
@@ -307,7 +307,12 @@ guix system search anonym network | grep "^name: tor"
# Verify that the examples can be built.
for example in gnu/system/examples/*.tmpl; do
- guix system -n disk-image "$example"
+ if echo "$example" | grep hurd; then
+ target="--target=i586-pc-gnu"
+ else
+ target=
+ fi
+ guix system -n disk-image $target "$example"
done
# Verify that the disk image types can be built.

to "fix" that. It feals a bit heavy, ugly and specific. Ideas?

Greetings, Janneke

--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com| Avatar® http://AvatarAcademy.com
L
L
Ludovic Courtès wrote on 6 Jun 2020 12:59
(name . Jan (janneke) Nieuwenhuizen)(address . janneke@gnu.org)(address . 41541@debbugs.gnu.org)
87sgf8v4r8.fsf@gnu.org
"Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> skribis:

Toggle quote (7 lines)
> 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.

Maybe make it a comment at the top of bare-hurd.tmpl?

Toggle quote (2 lines)
> See also: https://bugs.gnu.org/40839; wip-disk-image.

What does this mean?

Otherwise LGTM!
L
L
Ludovic Courtès wrote on 6 Jun 2020 13:05
Re: bug#41541: [PATCH 8/8] system: Add `hurd-activation'.
(name . Jan (janneke) Nieuwenhuizen)(address . janneke@gnu.org)(address . 41541@debbugs.gnu.org)
87o8pwv4ht.fsf@gnu.org
"Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> skribis:

Toggle quote (20 lines)
> +(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)

It seems that ‘command-line’ is unbound here, no?

I was wondering: if the only thing that differs between Linux and Mach
is the command line, could we keep the same activation script for both
cases, and instead move the conditional to (gnu build activation), like:

(if (string-contains %host-type "linux-gnu")
linux-command-line
mach-command-line)

Does that make sense?

Thanks,
Ludo’.
L
L
Ludovic Courtès wrote on 6 Jun 2020 13:08
Re: bug#41541: [PATCH 7/8] services: hurd: Add `hurd-etc-service'.
(name . Jan (janneke) Nieuwenhuizen)(address . janneke@gnu.org)(address . 41541@debbugs.gnu.org)
87k10kv4d0.fsf@gnu.org
"Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> skribis:

Toggle quote (4 lines)
> * gnu/services/hurd.scm: New file.
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
> * doc/guix.texi (Hurd Services): Document it.

[...]

Toggle quote (7 lines)
> +@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

The ‘hurd-default-essential-services’ bit is not in this patch, though.

Toggle quote (2 lines)
> +;;; The ETC service for the Hurd.

s/ETC/etc/

Toggle quote (23 lines)
> +(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"))))))

Why again does it need to be different from that on GNU/Linux?
Intuitively it should be the same, but it’s fine to keep this one,
perhaps with a FIXME, until we’ve figured out what to do to use the same
/etc service in both cases.

Ludo’.
J
J
Jan Nieuwenhuizen wrote on 6 Jun 2020 13:14
Re: bug#41541: [PATCH 1/8] system: Add 'hurd' field to <operating-system>.
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 41541@debbugs.gnu.org)
87tuzo30po.fsf@gnu.org
Ludovic Courtès writes:

Hello!

Toggle quote (26 lines)
> "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> skribis:
>
>> * 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
>
> Using GNU@tie{}Mach with the GNU@tie{}Hurd is experimental

Ok! (I think i tried to refer to the field "hurd", but I like your suggestion better)

Toggle quote (19 lines)
>> +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.
>
> To show that this field is not specific to disk/VM images, how about
> something along these lines:
>
> When this field is set, produce a GNU/Hurd operating system. In that
> case, @code{kernel} must also be set to the @code{gnumach}
> package---the microkernel the Hurd runs on.
>
> @quotation Warning
> This feature is experimental and only supported for disk images.
> @end quotation

Nice, thanks! Changed to

@item @code{hurd} (default: @code{#f})
The package object of the hurd to be started by the kernel. When this
field is set, produce a GNU/Hurd operating system. In that case,
@code{kernel} must also be set to the @code{gnumach} package---the
microkernel the Hurd runs on.

@quotation Warning
This feature is experimental and only supported for disk images.
@end quotation

Janneke

--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com| Avatar® http://AvatarAcademy.com
J
J
Jan Nieuwenhuizen wrote on 6 Jun 2020 14:00
Re: bug#41541: [PATCH 2/8] bootloader: Extend `<menu-entry>' for multiboot.
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 41541@debbugs.gnu.org)
87pnac2yle.fsf@gnu.org
Ludovic Courtès writes:

Toggle quote (9 lines)
> "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> skribis:
>
>> * 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.
>
> Could you mention the new fields in guix.texi?

Oops, I missed that. Added the "default #f" for the linux and initrd
fields, and this

@item @code{multiboot-kernel} (default: @code{#f})
The kernel to boot in Multiboot-mode (@pxref{multiboot,,, grub, GNU GRUB
manual}). When this field is set, a Multiboot menu-entry is generated.
For example:

@lisp
(file-append mach "/boot/gnumach")
@end lisp

@item @code{multiboot-arguments} (default: @code{()})
The list of extra command-line arguments for the multiboot-kernel.

@item @code{multiboot-modules} (default: @code{()})
The list of commands for loading Multiboot modules. For example:

@lisp
(list (list (file-append hurd "/hurd/ext2fs.static") "ext2fs"
@dots{})
(list (file-append libc "/lib/ld.so.1") "exec"
@dots{}))
@end lisp

Toggle quote (2 lines)
> Otherwise LGTM!

Thanks, Janneke

--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com| Avatar® http://AvatarAcademy.com
J
J
Jan Nieuwenhuizen wrote on 6 Jun 2020 14:08
Re: bug#41541: [PATCH 4/8] bootloader: grub: Add support for multiboot.
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 41541@debbugs.gnu.org)
87k10k2y7p.fsf@gnu.org
Ludovic Courtès writes:

Toggle quote (13 lines)
> "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> skribis:
>
>> * gnu/bootloader/grub.scm (grub-configuration-file): Add support for
>> multiboot.
>
> [...]
>
>> - #:export (menu-entry
>> + #:export (<menu-entry>
>
> Please don’t do that. In general we shouldn’t export record-type
> descriptors as it breaks encapsulation.

Hmm...okay, it's not needed per se. I rewrote the (match (($
<menu-entry>) ... ) to use accessors again!

Greetings, Janneke

--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com| Avatar® http://AvatarAcademy.com
J
J
Jan Nieuwenhuizen wrote on 6 Jun 2020 14:34
Re: bug#41541: [PATCH 6/8] system: examples: Add bare-hurd.tmpl.
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 41541@debbugs.gnu.org)
877dwk2x0u.fsf@gnu.org
Ludovic Courtès writes:

Toggle quote (11 lines)
> "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> skribis:
>
>> 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.
>
> Maybe make it a comment at the top of bare-hurd.tmpl?

Sure, moved there and...

...and adapted to say "disk-image".

Toggle quote (4 lines)
>> See also: https://bugs.gnu.org/40839; wip-disk-image.

> What does this mean?

Removed. This was from before our "explosive" mixture of the two wip
branches, as a courtesy for fellow Hurd hackers to get involved :-/

I tend to add extra stuff to commit messages and then forget to clean-up
later.

Toggle quote (2 lines)
> Otherwise LGTM!

Thanks, Janneke

--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com| Avatar® http://AvatarAcademy.com
J
J
Jan Nieuwenhuizen wrote on 6 Jun 2020 16:21
Re: bug#41541: [PATCH 8/8] system: Add `hurd-activation'.
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 41541@debbugs.gnu.org)
871rms2s1s.fsf@gnu.org
Ludovic Courtès writes:

Toggle quote (7 lines)
> "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> skribis:
>
>> +(define (hurd-activation-script gexps)
>> + (activate-current-system #:kernel-command-line command-line)
>
> It seems that ‘command-line’ is unbound here, no?

I don't think so...activation will be loaded from RC (following commit),
which is a guile script started by RUNSYSTEM:

Toggle snippet (4 lines)
...
exec ${system}/rc \"$@\"

Toggle quote (4 lines)
> I was wondering: if the only thing that differs between Linux and Mach
> is the command line, could we keep the same activation script for both
> cases, and instead move the conditional to (gnu build activation), like:
>
(if (string-contains %host-type "linux-gnu")
linux-command-line
mach-command-line)

Toggle quote (2 lines)
> Does that make sense?

Yes, much better now. Using (command-line), though.

This used to be much more complicated, when stuff didn't cross build
correctly etc.

Greetings,
Janneke

--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com| Avatar® http://AvatarAcademy.com
J
J
Jan Nieuwenhuizen wrote on 6 Jun 2020 16:31
Re: bug#41541: [PATCH 7/8] services: hurd: Add `hurd-etc-service'.
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 41541@debbugs.gnu.org)
87y2p01d1h.fsf@gnu.org
Ludovic Courtès writes:

Toggle quote (8 lines)
> "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org> skribis:
>
>> * gnu/services/hurd.scm: New file.
>> * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
>> * doc/guix.texi (Hurd Services): Document it.
>
> [...]

As discussed on IRC: dropped altogether, replaced with attached patch.

Toggle quote (9 lines)
>> +@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
>
> The ‘hurd-default-essential-services’ bit is not in this patch, though.

Hmm. I think it's complicated...No, it was complicated. ETC depends on
%activatation which depends on %boot, but those now work; so I can
reorder!

Reordered, added to hurd-default-essential-services in compliance with
the documentation.

Toggle quote (4 lines)
>> +;;; The ETC service for the Hurd.
>
> s/ETC/etc/

OK. Eh... ok. ;-)

Toggle quote (1 lines)
>> +(define (hurd-etc-service os)
[..]
Toggle quote (10 lines)
>> + (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"))))))
>
> Why again does it need to be different from that on GNU/Linux?

Good question! Yeah...this started out as a more formalized copy of the
gnu/system/hurd.scm hack and it used to be complicated; services didn't
cross build, for example.

Also, it felt good to start really minimalistic, especially because of
the cross build troubles.

I seemed to remember that on top of that there was a Hurd build problem,
but I think that must have been sudo and it's easy to disable.

Toggle quote (4 lines)
> Intuitively it should be the same, but it’s fine to keep this one,
> perhaps with a FIXME, until we’ve figured out what to do to use the same
> /etc service in both cases.

Phew, I didn't expect so much work; but also not so much cleanup so
soon.

Thanks, Janneke
From 4cef6e73ce9fd137640c1c00f98958cdc41dda90 Mon Sep 17 00:00:00 2001
From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org>
Date: Sat, 25 Apr 2020 11:55:56 +0200
Subject: [PATCH] services: Support etc-service for the Hurd.

* gnu/system.scm (operating-system-etc-service): Cater for missing nsswitch
and missing sudoers-file. For the Hurd, add "login" and "motd".
(hurd-default-essential-services): Add operating-system-etc-service.
---
gnu/system.scm | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)

Toggle diff (61 lines)
diff --git a/gnu/system.scm b/gnu/system.scm
index ac64dfcff6..0df642679d 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -611,6 +611,7 @@ bookkeeping."
(list (service system-service-type '())
%boot-service
%activation-service
+ (operating-system-etc-service os)
(service profile-service-type '())))
(define* (operating-system-services os)
@@ -716,7 +717,7 @@ This is the GNU system. Welcome.\n")
(define* (operating-system-etc-service os)
"Return a <service> that builds containing the static part of the /etc
directory."
- (let ((login.defs
+ (let* ((login.defs
(plain-file "login.defs"
(string-append
"# Default paths for non-login shells started by su(1).\n"
@@ -727,10 +728,13 @@ directory."
"/run/current-system/profile/bin:"
"/run/current-system/profile/sbin\n")))
- (issue (plain-file "issue" (operating-system-issue os)))
- (nsswitch (plain-file "nsswitch.conf"
- (name-service-switch->string
- (operating-system-name-service-switch os))))
+ (hurd (operating-system-hurd os))
+ (issue (plain-file "issue" (operating-system-issue os)))
+ (nsswitch (operating-system-name-service-switch os))
+ (nsswitch (and nsswitch
+ (plain-file "nsswitch.conf"
+ (name-service-switch->string nsswitch))))
+ (sudoers (operating-system-sudoers-file os))
;; Startup file for POSIX-compliant login shells, which set system-wide
;; environment variables.
@@ -820,7 +824,7 @@ fi\n")))
("rpc" ,(file-append net-base "/etc/rpc"))
("login.defs" ,#~#$login.defs)
("issue" ,#~#$issue)
- ("nsswitch.conf" ,#~#$nsswitch)
+ ,@(if nsswitch `(("nsswitch.conf" ,#~#$nsswitch)) '())
("profile" ,#~#$profile)
("bashrc" ,#~#$bashrc)
("hosts" ,#~#$(or (operating-system-hosts-file os)
@@ -836,7 +840,9 @@ fi\n")))
("timezone" ,(plain-file "timezone" (operating-system-timezone os)))
("localtime" ,(file-append tzdata "/share/zoneinfo/"
(operating-system-timezone os)))
- ("sudoers" ,(operating-system-sudoers-file os))))))
+ ,@(if sudoers `(("sudoers" ,sudoers)) '())
+ ,@(if hurd `(("login" ,(file-append hurd "/etc/login"))
+ ("motd" ,(file-append hurd "/etc/motd"))))))))
(define %root-account
;; Default root account.
--
2.26.2
--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com| Avatar® http://AvatarAcademy.com
M
M
Mathieu Othacehe wrote on 6 Jun 2020 18:49
Re: [bug#41541] [PATCH 6/8] system: examples: Add bare-hurd.tmpl.
(name . Jan Nieuwenhuizen)(address . janneke@gnu.org)
87a71gkulm.fsf@gnu.org
Hey,

Toggle quote (4 lines)
>
> Yes, I agree. Do you propose to hold back merging wip-hurd-vm until
> after merging the "image" catalog feature and then rewrite this message?

No, I have no clear objective for the catalog in mind, and as your serie
is almost ready, let's merge it first!

Toggle quote (15 lines)
> # Verify that the examples can be built.
> for example in gnu/system/examples/*.tmpl; do
> - guix system -n disk-image "$example"
> + if echo "$example" | grep hurd; then
> + target="--target=i586-pc-gnu"
> + else
> + target=
> + fi
> + guix system -n disk-image $target "$example"
> done
>
> # Verify that the disk image types can be built.
>
> to "fix" that. It feals a bit heavy, ugly and specific. Ideas?

It's somehow linked to the catalog subject. I think we should get rid of
this "examples" folder and provide something encapsulating the
system/target, the image and the operating-system, but I'm not sure how.

For now, I don't think that there's much better that the hack you're
proposing.

Thanks,

Mathieu
J
J
Jan Nieuwenhuizen wrote on 7 Jun 2020 00:44
(name . Mathieu Othacehe)(address . othacehe@gnu.org)
873677x19w.fsf@gnu.org
Mathieu Othacehe writes:

Hello Mathieu,

Toggle quote (6 lines)
>> Yes, I agree. Do you propose to hold back merging wip-hurd-vm until
>> after merging the "image" catalog feature and then rewrite this message?
>
> No, I have no clear objective for the catalog in mind, and as your serie
> is almost ready, let's merge it first!

Good; let's look at the last bits tomorrow. I think wip-hurd-vm should
be ready to merge (except of course the top "DRAFT" commit).

Toggle quote (22 lines)
>> # Verify that the examples can be built.
>> for example in gnu/system/examples/*.tmpl; do
>> - guix system -n disk-image "$example"
>> + if echo "$example" | grep hurd; then
>> + target="--target=i586-pc-gnu"
>> + else
>> + target=
>> + fi
>> + guix system -n disk-image $target "$example"
>> done
>>
>> # Verify that the disk image types can be built.
>>
>> to "fix" that. It feals a bit heavy, ugly and specific. Ideas?
>
> It's somehow linked to the catalog subject. I think we should get rid of
> this "examples" folder and provide something encapsulating the
> system/target, the image and the operating-system, but I'm not sure how.
>
> For now, I don't think that there's much better that the hack you're
> proposing.

Ok, all great then for now. Thank, Janneke

--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com| Avatar® http://AvatarAcademy.com
J
J
Jan Nieuwenhuizen wrote on 7 Jun 2020 09:39
Re: bug#41541: [PATCH 3/8] system: Add 'multiboot-modules' field to <boot-parameters>.
(name . Ludovic Courtès)(address . ludo@gnu.org)
87k10js4ss.fsf@gnu.org
Ludovic Courtès writes:

Hi,

Toggle quote (15 lines)
> Mathieu Othacehe <othacehe@gnu.org> skribis:
>
>>> + (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.
>
> If this hack is still needed, can we move it away to hurd-os.tmpl, or to
> the ‘gnumach’ package itself or something?

Yes, it's needed; GNUmach does not work when cross-built.

Toggle quote (2 lines)
> I think it’s best to keep (gnu system) free of any such assumptions.

Ok.

Changed this to

Toggle snippet (9 lines)
(define (operating-system-kernel-file os)
"Return an object representing the absolute file name of the kernel image of
OS."
(if (operating-system-hurd os)
(file-append (operating-system-kernel os) "/boot/gnumach")
(file-append (operating-system-kernel os)
"/" (system-linux-image-file-name))))

and compensated for MACH (folded in a later patch) in
gnu/system/hurd.scm, like

Toggle snippet (14 lines)
(define %hurd-default-operating-system-kernel
(if (hurd-system?)
gnumach
;; A cross-built GNUmach does not work
(with-parameters ((%current-system "i686-linux")
(%current-target-system #f))
gnumach)))
[...]
(define %hurd-default-operating-system
(operating-system
(kernel %hurd-default-operating-system-kernel)
[...]

Toggle quote (10 lines)
>>> + (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.
>
> Yeah, perhaps add a FIXME.

Yes, did that!

Toggle quote (5 lines)
>>> "--x-xattr-translator-records"
>
> Do we need this yet? If it can wait for later, that’s even nicer IMO as
> it would allow us to separate concerns.

Not "just" yet, it's used after the introduction of hurd-boot.scm, where
I use setxattr instead of MAKEDEV. Moved it up the stack, to

8dff3d0382 hurd-boot: Use setxattr instead of MAKEDEV.

Phew. I think that was it for this round. I've reset wip-hurd-vm so
that we can have another good look tomorrow.

Thanks a lot!
Janneke

--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com| Avatar® http://AvatarAcademy.com
L
L
Ludovic Courtès wrote on 7 Jun 2020 22:02
Re: bug#41541: [PATCH 7/8] services: hurd: Add `hurd-etc-service'.
(name . Jan Nieuwenhuizen)(address . janneke@gnu.org)(address . 41541@debbugs.gnu.org)
871rmqskzm.fsf@gnu.org
Hi,

Jan Nieuwenhuizen <janneke@gnu.org> skribis:

Toggle quote (9 lines)
> From 4cef6e73ce9fd137640c1c00f98958cdc41dda90 Mon Sep 17 00:00:00 2001
> From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org>
> Date: Sat, 25 Apr 2020 11:55:56 +0200
> Subject: [PATCH] services: Support etc-service for the Hurd.
>
> * gnu/system.scm (operating-system-etc-service): Cater for missing nsswitch
> and missing sudoers-file. For the Hurd, add "login" and "motd".
> (hurd-default-essential-services): Add operating-system-etc-service.

Perfect!
[...]

Toggle quote (4 lines)
> + ,@(if sudoers `(("sudoers" ,sudoers)) '())
> + ,@(if hurd `(("login" ,(file-append hurd "/etc/login"))
> + ("motd" ,(file-append hurd "/etc/motd"))))))))

We’re missing the ‘else’ branch here.

Apart from that, LGTM!

Thank you,
Ludo’.
J
J
Jan Nieuwenhuizen wrote on 7 Jun 2020 22:31
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 41541@debbugs.gnu.org)
874krmd3e5.fsf@gnu.org
Ludovic Courtès writes:

Hi,

Toggle quote (21 lines)
> Jan Nieuwenhuizen <janneke@gnu.org> skribis:
>
>> From 4cef6e73ce9fd137640c1c00f98958cdc41dda90 Mon Sep 17 00:00:00 2001
>> From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org>
>> Date: Sat, 25 Apr 2020 11:55:56 +0200
>> Subject: [PATCH] services: Support etc-service for the Hurd.
>>
>> * gnu/system.scm (operating-system-etc-service): Cater for missing nsswitch
>> and missing sudoers-file. For the Hurd, add "login" and "motd".
>> (hurd-default-essential-services): Add operating-system-etc-service.
>
> Perfect!
>
> [...]
>
>> + ,@(if sudoers `(("sudoers" ,sudoers)) '())
>> + ,@(if hurd `(("login" ,(file-append hurd "/etc/login"))
>> + ("motd" ,(file-append hurd "/etc/motd"))))))))
>
> We’re missing the ‘else’ branch here.

Toggle quote (2 lines)
> Apart from that, LGTM!

Great...getting there!
Janneke

--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com| Avatar® http://AvatarAcademy.com
J
J
Jan (janneke) Nieuwenhuizen wrote on 8 Jun 2020 14:57
[PATCH 0/4] Final wip-hurd-vm batch.
(address . 41541@debbugs.gnu.org)
20200608125802.10617-1-janneke@gnu.org
From: Jan Nieuwenhuizen <janneke@gnu.org>

Hi!

Almost done...these patches didn't see a review yet; I would like you to have
a look at the two hurd-boot patches. I have tested them both because I
decided to do the split-up a bit differently: first introduce the MAKEDEV
replacement and make the settrans invocation => setxattr syscall transition a
separate feature. Hope you like it :-)

Thanks!

Jan (janneke) Nieuwenhuizen (4):
hurd-boot: Create individual translators instead of running MAKEDEV.
system: hurd: Remove 'cross-hurd-image' hack.
system: bare-hurd.tmpl: Add openssh client and service.
hurd-boot: Use 'setxattr' instead of invoking settrans.

gnu/build/hurd-boot.scm | 172 ++++++++++++++++++++--------
gnu/system.scm | 1 +
gnu/system/examples/bare-hurd.tmpl | 13 ++-
gnu/system/hurd.scm | 177 +----------------------------
4 files changed, 140 insertions(+), 223 deletions(-)

--
2.26.2
J
J
Jan (janneke) Nieuwenhuizen wrote on 8 Jun 2020 14:57
[PATCH 1/4] hurd-boot: Create individual translators instead of running MAKEDEV.
(address . 41541@debbugs.gnu.org)
20200608125802.10617-2-janneke@gnu.org
* gnu/build/hurd-boot.scm (make-hurd-device-nodes): Do not create
dev/{null,zero,full,random,urandom} mount points.
(setup-translator, xattr-translator,
showtrans-translator?, translated?, set-hurd-device-translators): New
procedures.
(boot-hurd-system): Use them instead of running MAKEDEV.
---
gnu/build/hurd-boot.scm | 172 +++++++++++++++++++++++++++++-----------
1 file changed, 125 insertions(+), 47 deletions(-)

Toggle diff (212 lines)
diff --git a/gnu/build/hurd-boot.scm b/gnu/build/hurd-boot.scm
index 09326233d2..398cee1395 100644
--- a/gnu/build/hurd-boot.scm
+++ b/gnu/build/hurd-boot.scm
@@ -80,16 +80,8 @@ Return the value associated with OPTION, or #f on failure."
(string-append root (if (string-suffix? "/" root) "" "/") dir))
(mkdir (scope "dev"))
- (for-each (lambda (file)
- (call-with-output-file (scope file)
- (lambda (port)
- (display file port) ;avoid hard-linking
- (chmod port #o666))))
- '("dev/null"
- "dev/zero"
- "dev/full"
- "dev/random"
- "dev/urandom"))
+ ;; Don't create /dev/null etc just yet; the store
+ ;; messes-up the permission bits.
;; Don't create /dev/console, /dev/vcs, etc.: they are created by
;; console-run on first boot.
@@ -115,6 +107,125 @@ Return the value associated with OPTION, or #f on failure."
;; settings?
)
+(define (xattr-translator? file-name)
+ "Return true if FILE-NAME has an extended @code{gnu.translator} attribute
+set."
+ (false-if-exception
+ (not (string-null? (getxattr file-name "gnu.translator")))))
+
+(define (showtrans-translator? file-name)
+ "Return true if @file{showtrans} finds a translator installed on FILE-NAME."
+ (with-output-to-port (%make-void-port "w")
+ (lambda _
+ (with-error-to-port (%make-void-port "w")
+ (lambda _
+ (zero? (system* "showtrans" "--silent" file-name)))))))
+
+(define (translated? file-name)
+ "Return true if a translator is installed on FILE-NAME."
+ (if (string-contains %host-type "linux-gnu")
+ (xattr-translator? file-name)
+ (showtrans-translator? file-name)))
+
+(define* (setup-translator file-name command #:optional (mode #o600))
+ "Setup translator COMMAND on FILE-NAME."
+ (unless (translated? file-name)
+ (let ((dir (dirname file-name)))
+ (unless (directory-exists? dir)
+ (mkdir-p dir))
+ (unless (file-exists? file-name)
+ (call-with-output-file file-name
+ (lambda (port)
+ (display file-name port) ;avoid hard-linking
+ (chmod port mode)))))
+ (catch 'system-error
+ (lambda _
+ (apply invoke "settrans" "--create" file-name command))
+ (lambda (key . args)
+ (let ((errno (system-error-errno (cons key args))))
+ (format (current-error-port) "~a: ~a\n"
+ (strerror errno) file-name)
+ (format (current-error-port) "Ignoring...Good Luck!\n"))))))
+
+(define* (set-hurd-device-translators #:optional (root "/"))
+ "Make some of the device nodes needed on GNU/Hurd."
+
+ (define (scope dir)
+ (string-append root (if (string-suffix? "/" root) "" "/") dir))
+
+ (define scope-setup-translator
+ (match-lambda
+ ((file-name command)
+ (scope-setup-translator (list file-name command #o600)))
+ ((file-name command mode)
+ (let ((mount-point (scope file-name)))
+ (setup-translator mount-point command mode)))))
+
+ (define servers
+ '(("servers/crash-dump-core" ("/hurd/crash" "--dump-core"))
+ ("servers/crash-kill" ("/hurd/crash" "--kill"))
+ ("servers/crash-suspend" ("/hurd/crash" "--suspend"))
+ ("servers/password" ("/hurd/password"))
+ ("servers/socket/1" ("/hurd/pflocal"))
+ ("servers/socket/2" ("/hurd/pfinet"
+ "--interface" "eth0"
+ "--address"
+ "10.0.2.15" ;the default QEMU guest IP
+ "--netmask" "255.255.255.0"
+ "--gateway" "10.0.2.2"
+ "--ipv6" "/servers/socket/16"))))
+
+ (define devices
+ '(("dev/full" ("/hurd/null" "--full") #o666)
+ ("dev/null" ("/hurd/null") #o666)
+ ("dev/random" ("/hurd/random" "--seed-file" "/var/lib/random-seed")
+ #o644)
+ ("dev/zero" ("/hurd/storeio" "--store-type=zero") #o666)
+
+ ("dev/console" ("/hurd/term" "/dev/console" "device" "console"))
+
+ ("dev/klog" ("/hurd/streamio" "kmsg"))
+ ("dev/mem" ("/hurd/storeio" "--no-cache" "mem") #o660)
+ ("dev/shm" ("/hurd/tmpfs" "--mode=1777" "50%") #o644)
+ ("dev/time" ("/hurd/storeio" "--no-cache" "time") #o644)
+
+ ("dev/vcs" ("/hurd/console"))
+ ("dev/tty" ("/hurd/magic" "tty") #o666)
+
+ ("dev/tty1" ("/hurd/term" "/dev/tty1" "hurdio" "/dev/vcs/1/console")
+ #o666)
+ ("dev/tty2" ("/hurd/term" "/dev/tty2" "hurdio" "/dev/vcs/2/console")
+ #o666)
+ ("dev/tty3" ("/hurd/term" "/dev/tty3" "hurdio" "/dev/vcs/3/console")
+ #o666)
+
+ ("dev/ptyp0" ("/hurd/term" "/dev/ptyp0" "pty-master" "/dev/ttyp0")
+ #o666)
+ ("dev/ptyp1" ("/hurd/term" "/dev/ptyp1" "pty-master" "/dev/ttyp1")
+ #o666)
+ ("dev/ptyp2" ("/hurd/term" "/dev/ptyp2" "pty-master" "/dev/ttyp2")
+ #o666)
+
+ ("dev/ttyp0" ("/hurd/term" "/dev/ttyp0" "pty-slave" "/dev/ptyp0")
+ #o666)
+ ("dev/ttyp1" ("/hurd/term" "/dev/ttyp1" "pty-slave" "/dev/ptyp1")
+ #o666)
+ ("dev/ttyp2" ("/hurd/term" "/dev/ttyp2" "pty-slave" "/dev/ptyp2")
+ #o666)))
+
+ (for-each scope-setup-translator servers)
+ (false-if-exception (mkdir-p (scope "dev/vcs/1")))
+ (false-if-exception (mkdir-p (scope "dev/vcs/2")))
+ (false-if-exception (mkdir-p (scope "dev/vcs/3")))
+ (false-if-exception (rename-file "/dev/console" "/dev/console-"))
+ (for-each scope-setup-translator devices)
+
+ (false-if-exception (symlink "/dev/random" "/dev/urandom"))
+ (false-if-exception (mkdir-p "/dev/fd"))
+ (false-if-exception (symlink "/dev/fd/0" "/dev/stdin"))
+ (false-if-exception (symlink "/dev/fd/1" "/dev/stdout"))
+ (false-if-exception (symlink "/dev/fd/2" "/dev/stderr")))
+
(define* (boot-hurd-system #:key (on-error 'debug))
"This procedure is meant to be called from an early RC script.
@@ -126,20 +237,9 @@ starting the Shepherd.
XXX TODO: see linux-boot.scm:boot-system.
XXX TODO: add proper file-system checking, mounting
XXX TODO: move bits to (new?) (hurd?) (activation?) services
-XXX TODO: use settrans/setxattr instead of MAKEDEV
+XXX TODO: use Linux xattr/setxattr to remove (settrans in) /libexec/RUNSYSTEM
"
- (define translators
- '(("/servers/crash-dump-core" ("/hurd/crash" "--dump-core"))
- ("/servers/crash-kill" ("/hurd/crash" "--kill"))
- ("/servers/crash-suspend" ("/hurd/crash" "--suspend"))
- ("/servers/password" ("/hurd/password"))
- ("/servers/socket/1" ("/hurd/pflocal"))
- ("/servers/socket/2" ("/hurd/pfinet" "--interface" "eth0"
- "--address" "10.0.2.15" ;the default QEMU guest IP
- "--netmask" "255.255.255.0"
- "--gateway" "10.0.2.2"
- "--ipv6" "/servers/socket/16"))))
(display "Welcome, this is GNU's early boot Guile.\n")
(display "Use '--repl' for an initrd REPL.\n\n")
@@ -147,35 +247,13 @@ XXX TODO: use settrans/setxattr instead of MAKEDEV
(call-with-error-handling
(lambda ()
- (define (translated? node)
- ;; Return true if a translator is installed on NODE.
- (with-output-to-port (%make-void-port "w")
- (lambda ()
- (with-error-to-port (%make-void-port "w")
- (lambda ()
- (zero? (system* "showtrans" "--silent" node)))))))
-
(let* ((args (command-line))
(system (find-long-option "--system" args))
(to-load (find-long-option "--load" args)))
- (format #t "Creating essential servers...\n")
- (setenv "PATH" (string-append system "/profile/bin"
- ":" system "/profile/sbin"))
- (for-each (match-lambda
- ((node command)
- (unless (translated? node)
- (mkdir-p (dirname node))
- (apply invoke "settrans" "--create" node command))))
- translators)
-
- (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"))
+ (format #t "Setting-up essential translators...\n")
+ (setenv "PATH" (string-append system "/profile/bin"))
+ (set-hurd-device-translators)
(false-if-exception (delete-file "/hurd"))
(let ((hurd/hurd (readlink* (string-append system "/profile/hurd"))))
--
2.26.2
J
J
Jan (janneke) Nieuwenhuizen wrote on 8 Jun 2020 14:58
[PATCH 2/4] system: hurd: Remove 'cross-hurd-image' hack.
(address . 41541@debbugs.gnu.org)
20200608125802.10617-3-janneke@gnu.org
The initial

guix build -f gnu/system/hurd.scm

hack has been superseded by regular guix system (cross) build.

* gnu/system/hurd.scm (compile-manifest, cross-hurd-image): Remove.
---
gnu/system/hurd.scm | 177 +-------------------------------------------
1 file changed, 3 insertions(+), 174 deletions(-)

Toggle diff (200 lines)
diff --git a/gnu/system/hurd.scm b/gnu/system/hurd.scm
index 956682357e..2205def577 100644
--- a/gnu/system/hurd.scm
+++ b/gnu/system/hurd.scm
@@ -39,16 +39,15 @@
#:use-module (gnu system)
#:use-module (gnu system shadow)
#:use-module (gnu system vm)
- #:export (cross-hurd-image
- %base-packages/hurd
+ #:export (%base-packages/hurd
%base-services/hurd
%hurd-default-operating-system
%hurd-default-operating-system-kernel))
;;; Commentary:
;;;
-;;; This module provides tools to (cross-)build GNU/Hurd virtual machine
-;;; images.
+;;; This module provides system-specifics for the GNU/Hurd operating system
+;;; and virtual machine.
;;;
;;; Code:
@@ -104,173 +103,3 @@
(pam-services '())
(setuid-programs '())
(sudoers-file #f)))
-
-(define* (cross-hurd-image #:key (hurd hurd) (gnumach gnumach))
- "Return a cross-built GNU/Hurd image."
-
- (define (cross-built thing)
- (with-parameters ((%current-target-system "i586-pc-gnu"))
- thing))
-
- (define (cross-built-entry entry)
- (manifest-entry
- (inherit entry)
- (item (cross-built (manifest-entry-item entry)))
- (dependencies (map cross-built-entry
- (manifest-entry-dependencies entry)))))
-
- (define system-profile
- (profile
- (content
- (map-manifest-entries cross-built-entry
- (packages->manifest %base-packages/hurd)))))
-
- (define grub.cfg
- (let ((hurd (cross-built hurd))
- (mach (with-parameters ((%current-system "i686-linux"))
- gnumach))
- (libc (cross-libc "i586-pc-gnu")))
- (computed-file "grub.cfg"
- #~(call-with-output-file #$output
- (lambda (port)
- (format port "
-set timeout=2
-search.file ~a/boot/gnumach
-
-menuentry \"GNU\" {
- multiboot ~a/boot/gnumach root=device:hd0s1
- module ~a/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}' -T typed '${root}' \\
- '$(task-create)' '$(task-resume)'
- module ~a/lib/ld.so.1 exec ~a/hurd/exec '$(exec-task=task-create)'
-}\n"
- #+mach #+mach #+hurd
- #+libc #+hurd))))))
-
- (define fstab
- (plain-file "fstab"
- "# This file was generated from your Guix configuration. Any changes
-# will be lost upon reboot or reconfiguration.
-
-/dev/hd0s1 / ext2 defaults
-"))
-
- (define passwd
- (plain-file "passwd"
- "root:x:0:0:root:/root:/bin/sh
-guixbuilder:x:1:1:guixbuilder:/var/empty:/bin/no-sh
-"))
-
- (define group
- (plain-file "group"
- "guixbuild:x:1:guixbuilder
-"))
-
- (define shadow
- (plain-file "shadow"
- "root::0:0:0:0:::
-"))
-
- (define etc-profile
- (plain-file "profile"
- "\
-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"))
-
- (define hurd-directives
- `((directory "/servers")
- ,@(map (lambda (server)
- `(file ,(string-append "/servers/" server)))
- '("startup" "exec" "proc" "password"
- "default-pager" "crash-dump-core"
- "kill" "suspend"))
- ("/servers/crash" -> "crash-dump-core")
- (directory "/servers/socket")
- (file "/servers/socket/1")
- (file "/servers/socket/2")
- (file "/servers/socket/16")
- ("/servers/socket/local" -> "1")
- ("/servers/socket/inet" -> "2")
- ("/servers/socket/inet6" -> "16")
- (directory "/boot")
- ("/boot/grub.cfg" -> ,grub.cfg) ;XXX: not strictly needed
- ("/hurd" -> ,(file-append (with-parameters ((%current-target-system
- "i586-pc-gnu"))
- hurd)
- "/hurd"))
-
- ;; TODO: Create those during activation, eventually.
- (directory "/root")
- (file "/root/.guile"
- ,(object->string
- '(begin
- (use-modules (ice-9 readline) (ice-9 colorized))
- (activate-readline) (activate-colorized))))
- (directory "/run")
- (directory "/run/current-system")
- ("/run/current-system/profile" -> ,system-profile)
- ("/etc/profile" -> ,etc-profile)
- ("/etc/fstab" -> ,fstab)
- ("/etc/group" -> ,group)
- ("/etc/passwd" -> ,passwd)
- ("/etc/shadow" -> ,shadow)
- (file "/etc/hostname" "guixygnu")
- (file "/etc/resolv.conf"
- "nameserver 10.0.2.3\n")
- ("/etc/services" -> ,(file-append (with-parameters ((%current-target-system
- "i586-pc-gnu"))
- net-base)
- "/etc/services"))
- ("/etc/protocols" -> ,(file-append (with-parameters ((%current-target-system
- "i586-pc-gnu"))
- net-base)
- "/etc/protocols"))
- ("/etc/motd" -> ,(file-append (with-parameters ((%current-target-system
- "i586-pc-gnu"))
- hurd)
- "/etc/motd"))
- ("/etc/login" -> ,(file-append (with-parameters ((%current-target-system
- "i586-pc-gnu"))
- hurd)
- "/etc/login"))
-
-
- ;; XXX can we instead, harmlessly set _PATH_TTYS (from glibc) in runttys.c?
- ("/etc/ttys" -> ,(file-append (with-parameters ((%current-target-system
- "i586-pc-gnu"))
- hurd)
- "/etc/ttys"))
- ("/bin/sh" -> ,(file-append (with-parameters ((%current-target-system
- "i586-pc-gnu"))
- bash)
- "/bin/sh"))))
-
- (qemu-image #:file-system-type "ext2"
- #:file-system-options '("-o" "hurd")
- #:device-nodes 'hurd
- #:inputs `(("system" ,system-profile)
- ("grub.cfg" ,grub.cfg)
- ("fstab" ,fstab)
- ("passwd" ,passwd)
- ("group" ,group)
- ("etc-profile" ,etc-profile)
- ("shadow" ,shadow))
- #:copy-inputs? #t
- #:os system-profile
- #:bootcfg-drv grub.cfg
- #:bootloader grub-bootloader
- #:register-closures? #f
- #:extra-directives hurd-directives))
-
-;; Return this thunk so one can type "guix build -f gnu/system/hurd.scm".
-cross-hurd-image
--
2.26.2
J
J
Jan (janneke) Nieuwenhuizen wrote on 8 Jun 2020 14:58
[PATCH 3/4] system: bare-hurd.tmpl: Add openssh client and service.
(address . 41541@debbugs.gnu.org)
20200608125802.10617-4-janneke@gnu.org
This:

./pre-inst-env guix system disk-image --no-grafts --target=i586-pc-gnu \
gnu/system/examples/bare-hurd.tmpl

now produces a VM image with functional ssh daemon that you may run like

guix environment --ad-hoc qemu -- qemu-system-i386 -enable-kvm -m 512M \
-device rtl8139,netdev=net0 -netdev user,id=net0,hostfwd=tcp:127.0.0.1:10022-:2222 \
-snapshot -hda <the-image>

and use like

ssh -p 10022 root@localhost
guix build -e '(@@ (gnu packages commencement) gnu-make-boot0)'

or even (if you use --image-size=3G)

guix build hello

* gnu/system/examples/bare-hurd.tmpl (%hurd-os)[packages]: Add openssh.
[services]: Add openssh-service.
---
gnu/system/examples/bare-hurd.tmpl | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

Toggle diff (32 lines)
diff --git a/gnu/system/examples/bare-hurd.tmpl b/gnu/system/examples/bare-hurd.tmpl
index 16f20416aa..6b421550b7 100644
--- a/gnu/system/examples/bare-hurd.tmpl
+++ b/gnu/system/examples/bare-hurd.tmpl
@@ -11,6 +11,8 @@
;; it boots, but needs activation, more setup and services to be useful.
(use-modules (gnu) (gnu system hurd) (guix utils))
+(use-service-modules ssh)
+(use-package-modules ssh)
(define %hurd-os
(operating-system
@@ -25,7 +27,14 @@
%base-file-systems))
(host-name "guixygnu")
(timezone "Europe/Amsterdam")
- (packages %base-packages/hurd)
- (services %base-services/hurd)))
+ (packages (cons openssh %base-packages/hurd))
+ (services (cons (service openssh-service-type
+ (openssh-configuration
+ (use-pam? #f)
+ (port-number 2222)
+ (permit-root-login #t)
+ (allow-empty-passwords? #t)
+ (password-authentication? #t)))
+ %base-services/hurd))))
%hurd-os
--
2.26.2
J
J
Jan (janneke) Nieuwenhuizen wrote on 8 Jun 2020 14:58
[PATCH 4/4] hurd-boot: Use 'setxattr' instead of invoking settrans.
(address . 41541@debbugs.gnu.org)
20200608125802.10617-5-janneke@gnu.org
Note: Using `getxattr' on the Hurd instead of running showtrans does not
work (yet?).

* gnu/build/hurd-boot.scm (setup-translator): Use 'setxattr' instead of
invoking settrans.
* gnu/system.scm (hurd-multiboot-modules): Add --x-xattr-translator-records to
enable xattr-embebbing of translators.
---
gnu/build/hurd-boot.scm | 2 +-
gnu/system.scm | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)

Toggle diff (27 lines)
diff --git a/gnu/build/hurd-boot.scm b/gnu/build/hurd-boot.scm
index 398cee1395..8150aff972 100644
--- a/gnu/build/hurd-boot.scm
+++ b/gnu/build/hurd-boot.scm
@@ -140,7 +140,7 @@ set."
(chmod port mode)))))
(catch 'system-error
(lambda _
- (apply invoke "settrans" "--create" file-name command))
+ (setxattr file-name "gnu.translator" (string-join command "\0" 'suffix)))
(lambda (key . args)
(let ((errno (system-error-errno (cons key args))))
(format (current-error-port) "~a: ~a\n"
diff --git a/gnu/system.scm b/gnu/system.scm
index 21d0fbd190..c6feea08f9 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -1190,6 +1190,7 @@ a list of <menu-entry>, to populate the \"old entries\" menu."
"--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
--
2.26.2
J
J
Jan Nieuwenhuizen wrote on 8 Jun 2020 15:23
Re: [PATCH 3/4] system: bare-hurd.tmpl: Add openssh client and service.
(address . 41541@debbugs.gnu.org)
87r1up669x.fsf@gnu.org
Jan (janneke) Nieuwenhuizen writes:

Oops ... to fast.

Moved comment in commit message into bare-hurd.tmpl, and update do use
openssh-sans-x instead.

New patch attached, sorry :-)
Janneke
From 97abb4aeab3aecc6f4b8177e61d588a64116666d Mon Sep 17 00:00:00 2001
From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org>
Date: Thu, 7 May 2020 19:14:07 +0200
Subject: [PATCH 3/4] system: bare-hurd.tmpl: Add openssh-sans-x client and
service.

* gnu/system/examples/bare-hurd.tmpl (%hurd-os)[packages]: Add openssh-sans-x.
[services]: Add openssh-service. Add example usage.
---
gnu/system/examples/bare-hurd.tmpl | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)

Toggle diff (50 lines)
diff --git a/gnu/system/examples/bare-hurd.tmpl b/gnu/system/examples/bare-hurd.tmpl
index 16f20416aa..cdde80200c 100644
--- a/gnu/system/examples/bare-hurd.tmpl
+++ b/gnu/system/examples/bare-hurd.tmpl
@@ -8,9 +8,24 @@
;; ./pre-inst-env guix system disk-image --target=i586-pc-gnu --no-grafts \
;; gnu/system/examples/bare-hurd.tmpl
;;
-;; it boots, but needs activation, more setup and services to be useful.
+;; You may run it like so
+;;
+;; guix environment --ad-hoc qemu -- qemu-system-i386 -enable-kvm -m 512M \
+;; -device rtl8139,netdev=net0 -netdev user,id=net0,hostfwd=tcp:127.0.0.1:10022-:2222 \
+;; -snapshot -hda <the-image>
+;;
+;; and use it like
+;;
+;; ssh -p 10022 root@localhost
+;; guix build -e '(@@ (gnu packages commencement) gnu-make-boot0)'
+;;
+;; or even (if you use --image-size=3G)
+;;
+;; guix build hello
(use-modules (gnu) (gnu system hurd) (guix utils))
+(use-service-modules ssh)
+(use-package-modules ssh)
(define %hurd-os
(operating-system
@@ -25,7 +40,15 @@
%base-file-systems))
(host-name "guixygnu")
(timezone "Europe/Amsterdam")
- (packages %base-packages/hurd)
- (services %base-services/hurd)))
+ (packages (cons openssh-sans-x %base-packages/hurd))
+ (services (cons (service openssh-service-type
+ (openssh-configuration
+ (openssh openssh-sans-x)
+ (use-pam? #f)
+ (port-number 2222)
+ (permit-root-login #t)
+ (allow-empty-passwords? #t)
+ (password-authentication? #t)))
+ %base-services/hurd))))
%hurd-os
--
2.26.2
--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com| Avatar® http://AvatarAcademy.com
J
J
Jan Nieuwenhuizen wrote on 13 Jun 2020 09:24
(address . 41541@debbugs.gnu.org)
87ftazh1h2.fsf@gnu.org
Jan (janneke) Nieuwenhuizen writes:

Toggle quote (4 lines)
> * gnu/system/examples/bare-hurd.tmpl (%hurd-os)[packages]: Add openssh.
> [services]: Add openssh-service.
> ---

Moved instructions from commit message to bare-hurd.tmpl and
Pushed to master as edbc067138fa417d03cbb204511d8b08b61a3d4d

Thank you!

--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com| Avatar® http://AvatarAcademy.com
J
J
Jan Nieuwenhuizen wrote on 13 Jun 2020 12:49
Re: [PATCH 2/4] system: hurd: Remove 'cross-hurd-image' hack.
(address . 41541@debbugs.gnu.org)
87k10bdyvb.fsf@gnu.org
Jan (janneke) Nieuwenhuizen writes:

Toggle quote (9 lines)
> The initial
>
> guix build -f gnu/system/hurd.scm
>
> hack has been superseded by regular guix system (cross) build.
>
> * gnu/system/hurd.scm (compile-manifest, cross-hurd-image): Remove.
> ---

Pushed to master as 60fdd9e3896bcd31e0b6ec29ac46d92aa8558565

--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com| Avatar® http://AvatarAcademy.com
J
J
Jan Nieuwenhuizen wrote on 14 Jun 2020 18:46
Re: [bug#41541] [PATCH 2/4] system: hurd: Remove 'cross-hurd-image' hack.
(address . 41541-done@debbugs.gnu.org)
87imft8uiy.fsf@gnu.org
Jan Nieuwenhuizen writes:

Toggle quote (2 lines)
> Pushed to master as 60fdd9e3896bcd31e0b6ec29ac46d92aa8558565

Hurd is merged, serviced, done, closing.

\o/

Thank you so much for getting this done.

And let this be the beginning of much more Hurd!
Janneke

--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com| Avatar® http://AvatarAcademy.com
Closed
M
M
Mathieu Othacehe wrote on 14 Jun 2020 19:48
Re: bug#41541: [PATCH 2/4] system: hurd: Remove 'cross-hurd-image' hack.
(address . 41541@debbugs.gnu.org)(address . janneke@gnu.org)
87r1uh7d30.fsf@gnu.org
Toggle quote (8 lines)
>> Pushed to master as 60fdd9e3896bcd31e0b6ec29ac46d92aa8558565
>
> Hurd is merged, serviced, done, closing.
>
> \o/
>
> Thank you so much for getting this done.

That's terrific, congrats!

Mathieu
L
L
Ludovic Courtès wrote on 14 Jun 2020 22:29
Re: [bug#41541] [PATCH 2/4] system: hurd: Remove 'cross-hurd-image' hack.
(name . Jan Nieuwenhuizen)(address . janneke@gnu.org)
87d061tmpt.fsf@gnu.org
Jan Nieuwenhuizen <janneke@gnu.org> skribis:

Toggle quote (12 lines)
> Jan Nieuwenhuizen writes:
>
>> Pushed to master as 60fdd9e3896bcd31e0b6ec29ac46d92aa8558565
>
> Hurd is merged, serviced, done, closing.
>
> \o/
>
> Thank you so much for getting this done.
>
> And let this be the beginning of much more Hurd!

Woohoo! Congrats, and thanks for all the hard work & patience!
Now’s the time to have some more fun, indeed!

Ludo’.
Closed
?