Re: 20/36: system: hurd: Add the Shepherd.

2020-05-01 Thread Jan Nieuwenhuizen
Ludovic Courtès writes:

Hi Ludo'!

>> commit bb17242a511014e1691d494b17152865db0580e0
>> Author: Jan (janneke) Nieuwenhuizen 
>> AuthorDate: Tue Apr 7 08:03:03 2020 +0200
>>
>> system: hurd: Add the Shepherd.

>> +  (define shepherd.conf
>> +(with-parameters ((%current-target-system "i586-pc-gnu"))
>> +  (shepherd-configuration-file (hurd-shepherd-services %hurd-os
>
> This looks like an intermediate before fully using the service/OS
> framework

TL;DR: Thanks a lot for your review and questions!  I will be using this
to rewrite the Shepherd/services introduction in a proper way, until
it can be merged.

> , but I wonder how much it helps.

Yes, that's exactly it!  This intermediate, is curerently the only way I
found that can produce a fully functional VM-image; i.e., one that
starts guix-daemon and openssh.  So it helps by being an intermediate.

> The way I see it, now that you’ve defined services for Hurd-specific
> things like the console client, you could very much write:
>
>   (operating-system
> ;; …
> (kernel gnumach)
> (hurd hurd)  ;<- we probably need this new field

(oh...prolly better than the (if hurd-target?) I've been sprinkling and
implicit adding of gnumach.  I'll have a go at this.

> (essential-services (hurd-essential-services this-operating-system))
> (services %base-hurd-services))
>
> (Eventually we can even arrange for ‘essential-services’ and ‘services’
> to pick the right default as a function of the chosen kernel.)
>
> and then do:
>
>   guix system build --target=i586-pc-gnu the-config-above.scm

> Assuming system cross-compilation works as advertised :-), it should
> cross-compile the whole system.

Yeah...is seems that the marketing department may have sold us something
that has yet to be delivered.  Either that, or I failed to read some
bits of the instruction manual ;-)

To get something to run, we need (near the top of wip-hurd-vm)

6302837257 HACK Don't fail on running host's localedef.
443e1b2176 gnu: hurd: Cross-build hack: Set target i586-pc-gnu if unset.
87b50146ee gnu: glibc/hurd-headers: Cross-build fix for the Hurd.

So, on a well-chosen version of wip-hurd-vm (for example: wip-hurd-vm24
on my gitlab), I can now finally run this

./pre-inst-env guix system build --target=i586-pc-gnu 
gnu/system/examples/bare-hurd.tmpl

...but (most of) the OS is not cross-compiled; /bin/bash is the
build host's bash.  Some things, like Grub, Gnumach, the Hurd are cross
compiled, so ...

> At that stage, you don’t need ‘cross-hurd-image’ any longer and you can
> instead run:
>
>   guix system vm-image --target=i586-pc-gnu the-config-above.scm
>
> to achieve the same result.

... indeed, running:

./pre-inst-env guix system vm-image --target=i586-pc-gnu 
gnu/system/examples/bare-hurd.tmpl

creates a bootable VM-image that drops into a bash-minimal shell,
because /bin/bash cannot be executed.

> But!  There’s one missing bit: a Hurdish grub.cfg.  I think that can be
> hacked in (gnu bootloader grub), by inheriting from ‘grub-bootloader’
> and providing a custom ‘configuration-file-generator’ field and maybe
> ‘installer’ as well.

I think I have that covered here

d6ec2c2543 * system: hurd: Add hurd-grub-configuration-file.
a9a6b716d9 * system: hurd: Add hurd-grub-minimal-bootloader.

possibly depending on these

4fd4296325 * system: Add hurd-operating-system-directory-base-entries.
f4f872a440 * services: hurd: Move hurd-default-essential-services.
5f7c73d83a * services: Add hurd-file-systems-service-type.
d7cd2f122d * services: hurd: Move hurd-etc-sevcices.

> Thus, (gnu system hurd) would be left with nothing but the definitions
> of ‘%base-services/hurd’, ‘%base-packages/hurd’, and so on.
> ‘hurd-essential-services’ could maybe go to (gnu services hurd).

Yes!

> But I wonder if I’m missing something, WDYT?

You're right...and this is what I am trying to work towards.  The reason
for me to introduce these intermediate steps is that they enable to run
intermediate tests.

Currently, "guix build -f gnu/system/hurd.scm" is the only way I have
that produces a functional VM.  We are pretty close t creating such a
thing with "guix system ...", but to do so we need a cross build that
works and a shepherd config generated...and that all needs to come
together.  So instead of attempting a giant leap, I'm trying to throw
some intermediate stepping stones in the pond :-)

We don't need to merge, or keep this history; but I don't see how to
walk this path without going round these extra curves; let alone getting
feedback or asking questions.  So I can imagine that these commits keep
being rewritten/removed on wip-hurd-vm until everything works.

> Thanks for the exciting developments again!  :-)

Thanks for your insights, we're getting there...  I have some more
specific, related questions/puzzles in response to your other mail about
services.

Greetings,
janneke

-- 
Jan Nieuwenhuizen  | GNU LilyPond 

Re: 20/36: system: hurd: Add the Shepherd.

2020-04-30 Thread Ludovic Courtès
guix-comm...@gnu.org skribis:

> commit bb17242a511014e1691d494b17152865db0580e0
> Author: Jan (janneke) Nieuwenhuizen 
> AuthorDate: Tue Apr 7 08:03:03 2020 +0200
>
> system: hurd: Add the Shepherd.
> 
> This starts console and ttys using the Shepherd.  Shepherd is not running 
> as
> PID 1 yet, its started from `rc'.
> 
> * gnu/system/hurd.scm (%base-packages/hurd): Add "shepherd".
> (%base-services/hurd): New variable.
> (%hurd-os): New variable.
> (hurd-shepherd-services): New function.
> (cross-hurd-image): Use them to generate an (unused and incomplete) ...
> (shepherd.conf): Generate from services defined in
> %hurd-os.
> * gnu/packages/hurd.scm (hurd-rc-script): Do not start console, start the
> shepherd instead.
> (hurd)[arguments]: Create pty devices.
> * gnu/system/hurd.scm (shepherd.conf): New file.

[...]

> +;; XXX: We will replace this by addding (gnu services shepherd).
> +(define shepherd-configuration-file
> +  (@@ (gnu services shepherd) shepherd-configuration-file))
> +
>  (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
> +  (list (service user-processes-service-type)
> +(service hurd-console-service-type
> + (hurd-console-configuration (hurd hurd)))
> +(service hurd-ttys-service-type
> + (hurd-ttys-configuration (hurd hurd)
> +
> +(define %hurd-os
> +  (operating-system
> +(host-name "guixygnu")
> +(bootloader #f)
> +(file-systems '())
> +(timezone "GNUrope")
> +(services %base-services/hurd)))
> +
> +(define (hurd-shepherd-services os)
> +  (append-map hurd-service->shepherd-service (operating-system-services os)))
>  
>  (define* (cross-hurd-image #:key (hurd hurd) (gnumach gnumach))
>"Return a cross-built GNU/Hurd image."
> @@ -136,6 +163,10 @@ if [ -f \"$GUIX_PROFILE/etc/profile\" ]; then
>. \"$GUIX_PROFILE/etc/profile\"
>  fi\n"))
>  
> +  (define shepherd.conf
> +(with-parameters ((%current-target-system "i586-pc-gnu"))
> +  (shepherd-configuration-file (hurd-shepherd-services %hurd-os

This looks like an intermediate before fully using the service/OS
framework, but I wonder how much it helps.

The way I see it, now that you’ve defined services for Hurd-specific
things like the console client, you could very much write:

  (operating-system
;; …
(kernel gnumach)
(hurd hurd)  ;<- we probably need this new field
(essential-services (hurd-essential-services this-operating-system))
(services %base-hurd-services))

(Eventually we can even arrange for ‘essential-services’ and ‘services’
to pick the right default as a function of the chosen kernel.)

and then do:

  guix system build --target=i586-pc-gnu the-config-above.scm

Assuming system cross-compilation works as advertised :-), it should
cross-compile the whole system.

At that stage, you don’t need ‘cross-hurd-image’ any longer and you can
instead run:

  guix system vm-image --target=i586-pc-gnu the-config-above.scm

to achieve the same result.

But!  There’s one missing bit: a Hurdish grub.cfg.  I think that can be
hacked in (gnu bootloader grub), by inheriting from ‘grub-bootloader’
and providing a custom ‘configuration-file-generator’ field and maybe
‘installer’ as well.

Thus, (gnu system hurd) would be left with nothing but the definitions
of ‘%base-services/hurd’, ‘%base-packages/hurd’, and so on.
‘hurd-essential-services’ could maybe go to (gnu services hurd).

But I wonder if I’m missing something, WDYT?

Thanks for the exciting developments again!  :-)

Ludo’.