[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#36555] [PATCH v4 1/3] guix system: Add 'reconfigure' module.
From: |
Ludovic Courtès |
Subject: |
[bug#36555] [PATCH v4 1/3] guix system: Add 'reconfigure' module. |
Date: |
Sat, 20 Jul 2019 16:29:46 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) |
Hello Jakob!
address@hidden (Jakob L. Kreuze) skribis:
> * guix/scripts/system/reconfigure.scm: New file.
> * Makefile.am (MODULES): Add it.
> * guix/scripts/system.scm (bootloader-installer-script): Export variable.
> * gnu/machine/ssh.scm (switch-to-system, upgrade-shepherd-services)
> (install-bootloader): Delete variable.
> * gnu/machine/ssh.scm (deploy-managed-host): Rewrite procedure.
> * gnu/services/herd.scm (live-service): Export variable.
> * gnu/services/herd.scm (live-service-canonical-name): New variable.
> * tests/services.scm (live-service): Delete variable.
It LGTM! I have some comments inline below, but nothing that should
block this patch.
> (define (deploy-managed-host machine)
> "Internal implementation of 'deploy-machine' for MACHINE instances with an
> environment type of 'managed-host."
> (maybe-raise-unsupported-configuration-error machine)
> - (mbegin %store-monad
> - (switch-to-system machine)
> - (upgrade-shepherd-services machine)
> - (install-bootloader machine)))
> + (mlet %store-monad ((boot-parameters (machine-boot-parameters machine)))
> + (let* ((os (machine-system machine))
> + (eval (cut machine-remote-eval machine <>))
> + (menu-entries (map boot-parameters->menu-entry boot-parameters))
> + (bootloader-configuration (operating-system-bootloader os))
> + (bootcfg (operating-system-bootcfg os menu-entries)))
> + (mbegin %store-monad
> + (switch-to-system eval os)
> + (upgrade-shepherd-services eval os)
> + (install-bootloader eval bootloader-configuration bootcfg)))))
Really nice that it becomes this concise.
>
> ;;;
> diff --git a/gnu/services/herd.scm b/gnu/services/herd.scm
> index 0008746fe..2207b2d34 100644
> --- a/gnu/services/herd.scm
> +++ b/gnu/services/herd.scm
> @@ -40,10 +40,12 @@
> unknown-shepherd-error?
> unknown-shepherd-error-sexp
>
> + live-service
I like to avoid exposing constructors so that one cannot “forge” invalid
objects, but let’s see…
> +(define* (switch-to-system eval os #:optional profile)
> + "Using EVAL, a monadic procedure taking a single G-Expression as an
> argument,
> +create a new generation of PROFILE pointing to the directory of OS, switch to
> +it atomically, and run OS's activation script."
> + (eval #~(primitive-load #$(switch-system-program os profile))))
I wonder it we should just use
#~(begin (use-modules (guix build utils)) (invoke …))
here and in other places.
That’s probably better longer-term (for example when we switch to
Guile 3, that could ease the transition since the right Guile would be
used) but we can keep it this way and revisit it later.
> +(define (running-services eval)
> + "Using EVAL, a monadic procedure taking a single G-Expression as an
> argument,
> +return the <live-service> objects that are currently running on MACHINE."
> + (define remote-exp
s/remote-exp/exp/
> + (with-imported-modules '((gnu services herd))
> + #~(begin
> + (use-modules (gnu services herd))
> + (let ((services (current-services)))
> + (and services
> + ;; 'live-service-running' is ignored, as we can't
> necessarily
> + ;; serialize arbitrary objects. This should be fine for now,
> + ;; since 'machine-current-services' is not exposed publicly,
> + ;; and the resultant <live-service> objects are only used
> for
> + ;; resolving service dependencies.
> + (map (lambda (service)
> + (list (live-service-provision service)
> + (live-service-requirement service)))
> + services))))))
> + (mlet %store-monad ((services (eval remote-exp)))
> + (return (map (match-lambda
> + ((provision requirement)
> + (live-service provision requirement #f)))
> + services))))
OK, that makes sense here.
(Once we’ve done that (guix graph) demonadification we discussed before,
perhaps we can perform run ‘shepherd-service-upgrade’ entirely on the
“other side”, and at that point we won’t need to expose the
‘live-service’ constructor.)
> +;; (format (current-error-port) "error: ~a~%" (condition-message c))
> +;; (format #t "bootloader successfully installed on '~a'~%"
> +;; #$device)
A leftover? :-)
These two statements disappeared in the process, but I think they’re
added back by one of the subsequent patches, right?
Thanks,
Ludo’.
- [bug#36555] [PATCH v6 1/3] guix system: Add 'reconfigure' module., (continued)
- [bug#36555] [PATCH v6 1/3] guix system: Add 'reconfigure' module., Jakob L. Kreuze, 2019/07/24
- [bug#36555] [PATCH v6 2/3] guix system: Reimplement 'reconfigure'., Jakob L. Kreuze, 2019/07/24
- [bug#36555] [PATCH v6 3/3] tests: Add reconfigure system test., Jakob L. Kreuze, 2019/07/24
- bug#36555: [PATCH v6 3/3] tests: Add reconfigure system test., Ludovic Courtès, 2019/07/26
- [bug#36555] [PATCH v6 3/3] tests: Add reconfigure system test., Jakob L. Kreuze, 2019/07/26
- [bug#36555] [PATCH v5 2/3] guix system: Reimplement 'reconfigure'., Ludovic Courtès, 2019/07/24
- [bug#36555] [PATCH v4 3/3] tests: Add reconfigure system test., Ludovic Courtès, 2019/07/23
- [bug#36555] [PATCH v4 3/3] tests: Add reconfigure system test., Jakob L. Kreuze, 2019/07/23
- [bug#36555] [PATCH v4 3/3] tests: Add reconfigure system test., Ludovic Courtès, 2019/07/24
- [bug#36555] [PATCH v4 2/3] guix system: Reimplement 'reconfigure'., Ludovic Courtès, 2019/07/20
- [bug#36555] [PATCH v4 1/3] guix system: Add 'reconfigure' module.,
Ludovic Courtès <=
- [bug#36555] [PATCH v4 1/3] guix system: Add 'reconfigure' module., Jakob L. Kreuze, 2019/07/30
- [bug#36555] [PATCH v4 1/3] guix system: Add 'reconfigure' module., Jakob L. Kreuze, 2019/07/19
- [bug#36555] [PATCH v3 0/3] Refactor out common behavior for system reconfiguration., Christopher Lemmer Webber, 2019/07/19
- [bug#36555] [PATCH v3 0/3] Refactor out common behavior for system reconfiguration., Jakob L. Kreuze, 2019/07/22
- [bug#36555] [PATCH v3 0/3] Refactor out common behavior for system reconfiguration., Christopher Lemmer Webber, 2019/07/22
[bug#36555] [PATCH 0/2] Refactor out common behavior for system reconfiguration., Christopher Lemmer Webber, 2019/07/09