guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

11/36: DRAFT system: hurd: Add the Shepherd.


From: guix-commits
Subject: 11/36: DRAFT system: hurd: Add the Shepherd.
Date: Fri, 1 May 2020 11:53:58 -0400 (EDT)

janneke pushed a commit to branch wip-hurd-vm
in repository guix.

commit 874fc1ffc9c4c1a45af1dc8cc04a6a5b84a008d6
Author: Jan (janneke) Nieuwenhuizen <address@hidden>
AuthorDate: Tue Apr 7 08:03:03 2020 +0200

    DRAFT 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.
---
 gnu/packages/hurd.scm | 14 +++++++----
 gnu/system/hurd.scm   | 66 +++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 73 insertions(+), 7 deletions(-)

diff --git a/gnu/packages/hurd.scm b/gnu/packages/hurd.scm
index 55c4071..3984e42 100644
--- a/gnu/packages/hurd.scm
+++ b/gnu/packages/hurd.scm
@@ -349,10 +349,13 @@ boot, since this cannot be done from GNU/Linux."
                          (apply invoke "settrans" "-c" node command))))
                     '#$translators)
 
-          ;; Start the oh-so-fancy console client.
-          (mkdir-p "/var/run")                    ;for the PID file
-          (invoke "console" "--daemonize" "-c" "/dev/vcs"
-                  "-d" "vga" "-d" "pc_kbd" "-d" "generic_speaker"))))
+          ;; Generate the ssh host keys.
+          (invoke "/run/current-system/profile/bin/ssh-keygen" "-A")
+          (mkdir-p "/var/run")                    ;for the PID files
+          ;; Hand over to the Shepherd
+          (false-if-exception (delete-file "/var/run/shepherd/socket"))
+          (invoke "/run/current-system/profile/bin/shepherd"
+                  "--config" "/etc/shepherd.conf"))))
 
   ;; FIXME: We want the program to use the cross-compiled Guile when
   ;; cross-compiling.  But why do we need to be explicit here?
@@ -469,7 +472,8 @@ fsysopts / --writable
 # MAKEDEV relies on pipes so this needs to be set up.
 settrans -c /servers/socket/1 /hurd/pflocal
 
-(cd /dev; MAKEDEV -D /dev std vcs tty{1,2,3,4,5,6})\n")))
+(cd /dev; MAKEDEV -D /dev std vcs tty{1,2,3,4,5,6})
+(cd /dev; MAKEDEV -D /dev ptyp{0,1,2,3})\n")))
 
                (substitute* "daemons/runsystem.hurd.sh"
                  (("export PATH")
diff --git a/gnu/system/hurd.scm b/gnu/system/hurd.scm
index 58bfdf8..9d27125 100644
--- a/gnu/system/hurd.scm
+++ b/gnu/system/hurd.scm
@@ -18,6 +18,7 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu system hurd)
+  #:use-module (srfi srfi-1)
   #:use-module (guix gexp)
   #:use-module (guix profiles)
   #:use-module (guix utils)
@@ -31,6 +32,10 @@
   #: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 system)
   #:use-module (gnu system vm)
   #:export (cross-hurd-image))
 
@@ -51,10 +56,33 @@
                       #:system system
                       #:target target))
 
+;; 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)))
+
+;; XXX Tempory hack using hurd-service->shepherd-service
+(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 +164,37 @@ if [ -f \"$GUIX_PROFILE/etc/profile\" ]; then
   . \"$GUIX_PROFILE/etc/profile\"
 fi\n"))
 
+  ;; XXX Ideally...almost...
+  (define shepherd.conf--Includes-fake-services
+    (with-parameters ((%current-target-system "i586-pc-gnu"))
+      (shepherd-configuration-file
+       (append-map list
+                   (service-value
+               (fold-services (operating-system-services os)
+                              #:target-type
+                              shepherd-root-service-type))))))
+
+  ;; XXX Uglier..closer to running...
+  (define shepherd.conf--Errors-out-on-missing-services
+    (with-parameters ((%current-target-system "i586-pc-gnu"))
+      (shepherd-configuration-file
+       (filter
+        (lambda (value)
+          ;; XXX Remove file-systems, loopback, syslogd, user-processes
+          ;; those are fake/don't work yet on the Hurd
+          (pk "prov" (memq (car (shepherd-service-provision value))
+                           '(console guix-daemon ssh-daemon ttys
+                                     user-processes))))
+        (service-value
+         (fold-services (operating-system-services os)
+                        #:target-type
+                        shepherd-root-service-type))))))
+
+  ;; XXX Tempory hack using hurd-service->shepherd-service
+  (define shepherd.conf
+    (with-parameters ((%current-target-system "i586-pc-gnu"))
+      (shepherd-configuration-file (hurd-shepherd-services os))))
+
   (define hurd-directives
     `((directory "/servers")
       ,@(map (lambda (server)
@@ -199,6 +258,7 @@ fi\n"))
                                                        "i586-pc-gnu"))
                                       hurd)
                                     "/etc/ttys"))
+      ("/etc/shepherd.conf" -> ,shepherd.conf)
       ("/bin/sh" -> ,(file-append (with-parameters ((%current-target-system
                                                      "i586-pc-gnu"))
                                     bash)
@@ -213,12 +273,14 @@ fi\n"))
                          ("passwd" ,passwd)
                          ("group" ,group)
                          ("etc-profile" ,etc-profile)
-                         ("shadow" ,shadow))
+                         ("shadow" ,shadow)
+                         ("shepherd.conf" ,shepherd.conf))
               #:copy-inputs? #t
               #:os system-profile
               #:bootcfg-drv grub.cfg
               #:bootloader grub-bootloader
               #:register-closures? #f
+              #:disk-image-size (* 10 (expt 2 30)) ;10GiB
               #:extra-directives hurd-directives))
 
 ;; Return this thunk so one can type "guix build -f gnu/system/hurd.scm".



reply via email to

[Prev in Thread] Current Thread [Next in Thread]