From 2f497d94e7f6574b0847025ce29eafaf858008ef Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Thu, 3 Dec 2020 11:53:53 +0100 Subject: image: Rename "raw" image-type to "efi-raw". * gnu/system/image.scm (raw-image-type): Rename to "efi-raw-image-type". * guix/scripts/system.scm (%default-options): Adapt accordingly. * doc/guix.texi: Ditto. Signed-off-by: Mathieu Othacehe --- guix/scripts/system.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guix/scripts/system.scm') diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 51c8cf2f76..eb7137b7a9 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -1143,7 +1143,7 @@ Some ACTIONS support additional ARGS.\n")) (debug . 0) (verbosity . #f) ;default (validate-reconfigure . ,ensure-forward-reconfigure) - (image-type . raw) + (image-type . efi-raw) (image-size . guess) (install-bootloader? . #t) (label . #f) -- cgit v1.2.3 From e74baa124592428f05b17562f180469e405037f3 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Sun, 17 Jan 2021 11:32:51 +0100 Subject: system: Rename 'disk-image' command 'image'. * guix/scripts/system.scm (system-derivation-for-action): Rename 'disk-image' command 'image'. Warn when using the now deprecated 'disk-image' command. (show-help): Adapt accordingly. (guix-system): Ditto. * tests/guix-system.sh: Ditto. * gnu/system/examples/bare-hurd.tmpl: Ditto. * doc/guix.texi (Building the Installation Image, Building the Installation Image for ARM Boards, Invoking guix pack, Invoking guix system): Adapt documentation. --- doc/guix.texi | 24 ++++++++++++------------ gnu/system/examples/bare-hurd.tmpl | 2 +- guix/scripts/system.scm | 21 ++++++++++++--------- tests/guix-system.sh | 4 ++-- 4 files changed, 27 insertions(+), 24 deletions(-) (limited to 'guix/scripts/system.scm') diff --git a/doc/guix.texi b/doc/guix.texi index 0a82219e7a..f02353d9fa 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -2661,7 +2661,7 @@ The installation image described above was built using the @command{guix system} command, specifically: @example -guix system disk-image -t iso9660 gnu/system/install.scm +guix system image -t iso9660 gnu/system/install.scm @end example Have a look at @file{gnu/system/install.scm} in the source tree, @@ -2678,7 +2678,7 @@ If you build a disk image and the bootloader is not available otherwise includes the bootloader, specifically: @example -guix system disk-image --system=armhf-linux -e '((@@ (gnu system install) os-with-u-boot) (@@ (gnu system install) installation-os) "A20-OLinuXino-Lime2")' +guix system image --system=armhf-linux -e '((@@ (gnu system install) os-with-u-boot) (@@ (gnu system install) installation-os) "A20-OLinuXino-Lime2")' @end example @code{A20-OLinuXino-Lime2} is the name of the board. If you specify an invalid @@ -31393,7 +31393,7 @@ size of the image. @cindex System images, creation in various formats @cindex Creating system images in various formats @item vm-image -@itemx disk-image +@itemx image @itemx docker-image Return a virtual machine, disk image, or Docker image of the operating system declared in @var{file} that stands alone. By default, @@ -31403,22 +31403,22 @@ a value. Docker images are built to contain exactly what they need, so the @option{--image-size} option is ignored in the case of @code{docker-image}. -@cindex disk-image, creating disk images -The @code{disk-image} command can produce various image types. The +@cindex image, creating disk images +The @code{image} command can produce various image types. The image type can be selected using the @option{--image-type} option. It defaults to @code{efi-raw}. When its value is @code{iso9660}, the @option{--label} option can be used to specify a volume ID with -@code{disk-image}. By default, the root file system of a disk image is +@code{image}. By default, the root file system of a disk image is mounted non-volatile; the @option{--volatile} option can be provided to -make it volatile instead. When using @code{disk-image}, the bootloader +make it volatile instead. When using @code{image}, the bootloader installed on the generated image is taken from the provided @code{operating-system} definition. The following example demonstrates how to generate an image that uses the @code{grub-efi-bootloader} bootloader and boot it with QEMU: @example -image=$(guix system disk-image --image-type=qcow2 \ - gnu/system/examples/lightweight-desktop.tmpl) +image=$(guix system image --image-type=qcow2 \ + gnu/system/examples/lightweight-desktop.tmpl) cp $image /tmp/my-image.qcow2 chmod +w /tmp/my-image.qcow2 qemu-system-x86_64 -enable-kvm -hda /tmp/my-image.qcow2 -m 1000 \ @@ -31431,7 +31431,7 @@ it can be copied as is to a USB stick, for instance. Assuming the image to it using the following command: @example -# dd if=$(guix system disk-image my-os.scm) of=/dev/sdc status=progress +# dd if=$(guix system image my-os.scm) of=/dev/sdc status=progress @end example The @code{--list-image-types} command lists all the available image @@ -31551,7 +31551,7 @@ of the image. @item --image-type=@var{type} @itemx -t @var{type} -For the @code{disk-image} action, create an image with given @var{type}. +For the @code{image} action, create an image with given @var{type}. When this option is omitted, @command{guix system} uses the @code{efi-raw} image type. @@ -31563,7 +31563,7 @@ When this option is omitted, @command{guix system} uses the for burning on CDs and DVDs. @item --image-size=@var{size} -For the @code{vm-image} and @code{disk-image} actions, create an image +For the @code{vm-image} and @code{image} actions, create an image of the given @var{size}. @var{size} may be a number of bytes, or it may include a unit as a suffix (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}). diff --git a/gnu/system/examples/bare-hurd.tmpl b/gnu/system/examples/bare-hurd.tmpl index e4b795ff27..135ed23cb6 100644 --- a/gnu/system/examples/bare-hurd.tmpl +++ b/gnu/system/examples/bare-hurd.tmpl @@ -5,7 +5,7 @@ ;; To build a disk image for a virtual machine, do ;; -;; ./pre-inst-env guix system disk-image --target=i586-pc-gnu \ +;; ./pre-inst-env guix system image --target=i586-pc-gnu \ ;; gnu/system/examples/bare-hurd.tmpl ;; ;; You may run it like so diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index eb7137b7a9..66225bff35 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -705,9 +705,11 @@ checking this by themselves in their 'check' procedure." image-size (* 70 (expt 2 20))) #:mappings mappings)) - ((disk-image) + ((image disk-image) (let* ((base-image (os->image os #:type image-type)) (base-target (image-target base-image))) + (when (eq? action 'disk-image) + (warning (G_ "'disk-image' is deprecated: use 'image' instead~%"))) (lower-object (system-image (image @@ -779,7 +781,7 @@ and TARGET arguments." "Perform ACTION for OS. INSTALL-BOOTLOADER? specifies whether to install bootloader; BOOTLOADER-TAGET is the target for the bootloader; TARGET is the target root directory; IMAGE-SIZE is the size of the image to be built, for -the 'vm-image' and 'disk-image' actions. IMAGE-TYPE is the type of image to +the 'vm-image' and 'image' actions. IMAGE-TYPE is the type of image to be built. When VOLATILE-ROOT? is #t, the root file system is mounted volatile. @@ -968,7 +970,7 @@ Some ACTIONS support additional ARGS.\n")) (display (G_ "\ vm-image build a freestanding virtual machine image\n")) (display (G_ "\ - disk-image build a disk image, suitable for a USB stick\n")) + image build a Guix System image\n")) (display (G_ "\ docker-image build a Docker image\n")) (display (G_ "\ @@ -994,15 +996,15 @@ Some ACTIONS support additional ARGS.\n")) (display (G_ " --list-image-types list available image types")) (display (G_ " - -t, --image-type=TYPE for 'disk-image', produce an image of TYPE")) + -t, --image-type=TYPE for 'image', produce an image of TYPE")) (display (G_ " --image-size=SIZE for 'vm-image', produce an image of SIZE")) (display (G_ " --no-bootloader for 'init', do not install a bootloader")) (display (G_ " - --volatile for 'disk-image', make the root file system volatile")) + --volatile for 'image', make the root file system volatile")) (display (G_ " - --label=LABEL for 'disk-image', label disk image with LABEL")) + --label=LABEL for 'image', label disk image with LABEL")) (display (G_ " --save-provenance save provenance information")) (display (G_ " @@ -1014,7 +1016,7 @@ Some ACTIONS support additional ARGS.\n")) (display (G_ " -N, --network for 'container', allow containers to access the network")) (display (G_ " - -r, --root=FILE for 'vm', 'vm-image', 'disk-image', 'container', + -r, --root=FILE for 'vm', 'vm-image', 'image', 'container', and 'build', make FILE a symlink to the result, and register it as a garbage collector root")) (display (G_ " @@ -1335,7 +1337,7 @@ argument list and OPTS is the option alist." (alist-cons 'argument arg result) (let ((action (string->symbol arg))) (case action - ((build container vm vm-image disk-image reconfigure init + ((build container vm vm-image image disk-image reconfigure init extension-graph shepherd-graph list-generations describe delete-generations roll-back @@ -1368,7 +1370,8 @@ argument list and OPTS is the option alist." (exit 1)) (case action - ((build container vm vm-image disk-image docker-image reconfigure) + ((build container vm vm-image image disk-image docker-image + reconfigure) (unless (or (= count 1) (and expr (= count 0))) (fail))) diff --git a/tests/guix-system.sh b/tests/guix-system.sh index e7e4c17e39..f5ddd1dda3 100644 --- a/tests/guix-system.sh +++ b/tests/guix-system.sh @@ -262,8 +262,8 @@ guix system vm "$tmpfile" -d | grep '\.drv$' drv1="`guix system vm "$tmpfile" -d`" drv2="`guix system vm "$tmpfile" -d`" test "$drv1" = "$drv2" -drv1="`guix system disk-image -t iso9660 "$tmpfile" -d`" -drv2="`guix system disk-image -t iso9660 "$tmpfile" -d`" +drv1="`guix system image -t iso9660 "$tmpfile" -d`" +drv2="`guix system image -t iso9660 "$tmpfile" -d`" test "$drv1" = "$drv2" make_user_config "group-that-does-not-exist" "users" -- cgit v1.2.3 From 95f72dcd7aece05e9252c93bef5a831f96cb5393 Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Fri, 22 Jan 2021 20:06:55 +0100 Subject: services: shepherd: Allow custom 'shepherd' package. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/services/shepherd.scm (): New record. (shepherd-boot-gexp, shepherd-root-service-type): Use it. (scm->go, shepherd-configuration-file): Allow passing custom shepherd package. * gnu/system.scm (operating-system-shepherd-service-names): Use the new record. * guix/scripts/system.scm (export-shepherd-graph): Adjust accordingly. * doc/guix.texi (Shepherd Services). Document it. Co-authored-by: Ludovic Courtès --- doc/guix.texi | 17 ++++++++++++++- gnu/services/shepherd.scm | 53 +++++++++++++++++++++++++++++++++++------------ gnu/system.scm | 10 +++++---- guix/scripts/system.scm | 3 ++- 4 files changed, 64 insertions(+), 19 deletions(-) (limited to 'guix/scripts/system.scm') diff --git a/doc/guix.texi b/doc/guix.texi index 9b65be3c9c..405b218289 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -32782,9 +32782,24 @@ The service type for the Shepherd ``root service''---i.e., PID@tie{}1. This is the service type that extensions target when they want to create shepherd services (@pxref{Service Types and Services}, for an example). -Each extension must pass a list of @code{}. +Each extension must pass a list of @code{}. Its +value must be a @code{shepherd-configuration}, as described below. @end defvr +@deftp {Data Type} shepherd-configuration +This data type represents the Shepherd's configuration. + +@table @code +@item shepherd (default: @code{shepherd}) +The Shepherd package to use. + +@item services (default: @code{'()}) +A list of @code{} to start. +You should probably use the service extension +mechanism instead (@pxref{Shepherd Services}). +@end table +@end deftp + @defvr {Scheme Variable} %shepherd-root-service This service represents PID@tie{}1. @end defvr diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm index d2f9776288..e2ec59f5aa 100644 --- a/gnu/services/shepherd.scm +++ b/gnu/services/shepherd.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2017 Clément Lassieur ;;; Copyright © 2018 Carlo Zancanaro ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen +;;; Copyright © 2021 Maxime Devos ;;; ;;; This file is part of GNU Guix. ;;; @@ -36,7 +37,12 @@ #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) - #:export (shepherd-root-service-type + #:export (shepherd-configuration + shepherd-configuration? + shepherd-configuration-shepherd + shepherd-configuration-services + + shepherd-root-service-type %shepherd-root-service shepherd-service-type @@ -76,7 +82,18 @@ ;;; Code: -(define (shepherd-boot-gexp services) +(define-record-type* + shepherd-configuration make-shepherd-configuration + shepherd-configuration? + (shepherd shepherd-configuration-shepherd + (default shepherd)) ; package + (services shepherd-configuration-services + (default '()))) ; list of + +(define (shepherd-boot-gexp config) + "Return a gexp starting the shepherd service." + (let ((shepherd (shepherd-configuration-shepherd config)) + (services (shepherd-configuration-services config))) #~(begin ;; Keep track of the booted system. (false-if-exception (delete-file "/run/booted-system")) @@ -95,7 +112,10 @@ ;; Start shepherd. (execl #$(file-append shepherd "/bin/shepherd") "shepherd" "--config" - #$(shepherd-configuration-file services)))) + #$(shepherd-configuration-file services shepherd))))) + +(define shepherd-packages + (compose list shepherd-configuration-shepherd)) (define shepherd-root-service-type (service-type @@ -103,20 +123,25 @@ ;; Extending the root shepherd service (aka. PID 1) happens by ;; concatenating the list of services provided by the extensions. (compose concatenate) - (extend append) + (extend (lambda (config extra-services) + (shepherd-configuration + (inherit config) + (services (append (shepherd-configuration-services config) + extra-services))))) (extensions (list (service-extension boot-service-type shepherd-boot-gexp) (service-extension profile-service-type - (const (list shepherd))))) + shepherd-packages))) + (default-value (shepherd-configuration)) (description "Run the GNU Shepherd as PID 1---i.e., the operating system's first process. The Shepherd takes care of managing services such as daemons by ensuring they are started and stopped in the right order."))) (define %shepherd-root-service - ;; The root shepherd service, aka. PID 1. Its parameter is a list of - ;; objects. - (service shepherd-root-service-type '())) + ;; The root shepherd service, aka. PID 1. Its parameter is a + ;; . + (service shepherd-root-service-type)) (define-syntax shepherd-service-type (syntax-rules (description) @@ -270,9 +295,9 @@ stored." #~(#$name #$doc #$proc))) (shepherd-service-actions service)))))))) -(define (scm->go file) +(define (scm->go file shepherd) "Compile FILE, which contains code to be loaded by shepherd's config file, -and return the resulting '.go' file." +and return the resulting '.go' file. SHEPHERD is used as shepherd package." (let-system (system target) (with-extensions (list shepherd) (computed-file (string-append (basename (scheme-file-name file) ".scm") @@ -294,11 +319,13 @@ and return the resulting '.go' file." #:options '(#:local-build? #t #:substitutable? #f))))) -(define (shepherd-configuration-file services) - "Return the shepherd configuration file for SERVICES." +(define (shepherd-configuration-file services shepherd) + "Return the shepherd configuration file for SERVICES. SHEPHERD is used +as shepherd package." (assert-valid-graph services) - (let ((files (map shepherd-service-file services))) + (let ((files (map shepherd-service-file services)) + (scm->go (cute scm->go <> shepherd))) (define config #~(begin (use-modules (srfi srfi-34) diff --git a/gnu/system.scm b/gnu/system.scm index 90ad368664..5bf2a85272 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -12,6 +12,7 @@ ;;; Copyright © 2020 Maxim Cournoyer ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen ;;; Copyright © 2020 Efraim Flashner +;;; Copyright © 2021 Maxime Devos ;;; ;;; This file is part of GNU Guix. ;;; @@ -1134,10 +1135,11 @@ we're running in the final root." (define (operating-system-shepherd-service-names os) "Return the list of Shepherd service names for OS." (append-map shepherd-service-provision - (service-value - (fold-services (operating-system-services os) - #:target-type - shepherd-root-service-type)))) + (shepherd-configuration-services + (service-value + (fold-services (operating-system-services os) + #:target-type + shepherd-root-service-type))))) (define* (operating-system-derivation os) "Return a derivation that builds OS." diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 66225bff35..19b8c5163c 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -915,7 +915,8 @@ Run 'herd status' to view the list of services on your system.\n")))))) (let* ((services (operating-system-services os)) (pid1 (fold-services services #:target-type shepherd-root-service-type)) - (shepherds (service-value pid1)) ;list of + ;; Get the list of . + (shepherds (shepherd-configuration-services (service-value pid1))) (sinks (filter (lambda (service) (null? (shepherd-service-requirement service))) shepherds))) -- cgit v1.2.3