mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-11 13:49:23 -05:00
services: unattended-upgrade: Add 'operating-system-expression' field.
* gnu/services/admin.scm (<unattended-upgrade-configuration>) [operating-system-expression]: New field. (unattended-upgrade-mcron-jobs): Honor it. * doc/guix.texi (Unattended Upgrades): Document it. Co-authored-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
parent
22e9b01bda
commit
5f63811032
2 changed files with 29 additions and 5 deletions
|
@ -22,7 +22,7 @@
|
||||||
@set SUBSTITUTE-URLS https://@value{SUBSTITUTE-SERVER-1} https://@value{SUBSTITUTE-SERVER-2}
|
@set SUBSTITUTE-URLS https://@value{SUBSTITUTE-SERVER-1} https://@value{SUBSTITUTE-SERVER-2}
|
||||||
|
|
||||||
@copying
|
@copying
|
||||||
Copyright @copyright{} 2012-2022 Ludovic Courtès@*
|
Copyright @copyright{} 2012-2023 Ludovic Courtès@*
|
||||||
Copyright @copyright{} 2013, 2014, 2016 Andreas Enge@*
|
Copyright @copyright{} 2013, 2014, 2016 Andreas Enge@*
|
||||||
Copyright @copyright{} 2013 Nikita Karetnikov@*
|
Copyright @copyright{} 2013 Nikita Karetnikov@*
|
||||||
Copyright @copyright{} 2014, 2015, 2016 Alex Kost@*
|
Copyright @copyright{} 2014, 2015, 2016 Alex Kost@*
|
||||||
|
@ -110,6 +110,7 @@ Copyright @copyright{} 2022 Simon Streit@*
|
||||||
Copyright @copyright{} 2022 (@*
|
Copyright @copyright{} 2022 (@*
|
||||||
Copyright @copyright{} 2022 John Kehayias@*
|
Copyright @copyright{} 2022 John Kehayias@*
|
||||||
Copyright @copyright{} 2022 Ivan Vilata-i-Balaguer@*
|
Copyright @copyright{} 2022 Ivan Vilata-i-Balaguer@*
|
||||||
|
Copyright @copyright{} 2023 Giacomo Leidi@*
|
||||||
|
|
||||||
Permission is granted to copy, distribute and/or modify this document
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||||
|
@ -21362,6 +21363,17 @@ Therefore, uses of @code{local-file} within @file{config.scm} will work
|
||||||
as expected. @xref{G-Expressions}, for information about
|
as expected. @xref{G-Expressions}, for information about
|
||||||
@code{local-file} and @code{file-append}.
|
@code{local-file} and @code{file-append}.
|
||||||
|
|
||||||
|
@item @code{operating-system-expression} (default: @code{#f})
|
||||||
|
This field specifies an expression that evaluates to the operating
|
||||||
|
system to use for the upgrade. If no value is provided the
|
||||||
|
@code{operating-system-file} field value is used.
|
||||||
|
|
||||||
|
@lisp
|
||||||
|
(unattended-upgrade-configuration
|
||||||
|
(operating-system-expression
|
||||||
|
#~(@@ (guix system install) installation-os)))
|
||||||
|
@end lisp
|
||||||
|
|
||||||
@item @code{services-to-restart} (default: @code{'(mcron)})
|
@item @code{services-to-restart} (default: @code{'(mcron)})
|
||||||
This field specifies the Shepherd services to restart when the upgrade
|
This field specifies the Shepherd services to restart when the upgrade
|
||||||
completes.
|
completes.
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||||
;;; Copyright © 2016-2022 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2016-2023 Ludovic Courtès <ludo@gnu.org>
|
||||||
;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
|
;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
|
||||||
|
;;; Copyright © 2023 Giacomo Leidi <goodoldpaul@autistici.org>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -58,6 +59,7 @@ (define-module (gnu services admin)
|
||||||
unattended-upgrade-configuration
|
unattended-upgrade-configuration
|
||||||
unattended-upgrade-configuration?
|
unattended-upgrade-configuration?
|
||||||
unattended-upgrade-configuration-operating-system-file
|
unattended-upgrade-configuration-operating-system-file
|
||||||
|
unattended-upgrade-configuration-operating-system-expression
|
||||||
unattended-upgrade-configuration-channels
|
unattended-upgrade-configuration-channels
|
||||||
unattended-upgrade-configuration-schedule
|
unattended-upgrade-configuration-schedule
|
||||||
unattended-upgrade-configuration-services-to-restart
|
unattended-upgrade-configuration-services-to-restart
|
||||||
|
@ -263,6 +265,8 @@ (define-record-type* <unattended-upgrade-configuration>
|
||||||
unattended-upgrade-configuration?
|
unattended-upgrade-configuration?
|
||||||
(operating-system-file unattended-upgrade-operating-system-file
|
(operating-system-file unattended-upgrade-operating-system-file
|
||||||
(default "/run/current-system/configuration.scm"))
|
(default "/run/current-system/configuration.scm"))
|
||||||
|
(operating-system-expression unattended-upgrade-operating-system-expression
|
||||||
|
(default #f))
|
||||||
(schedule unattended-upgrade-configuration-schedule
|
(schedule unattended-upgrade-configuration-schedule
|
||||||
(default "30 01 * * 0"))
|
(default "30 01 * * 0"))
|
||||||
(channels unattended-upgrade-configuration-channels
|
(channels unattended-upgrade-configuration-channels
|
||||||
|
@ -296,6 +300,14 @@ (define expiration
|
||||||
(define config-file
|
(define config-file
|
||||||
(unattended-upgrade-operating-system-file config))
|
(unattended-upgrade-operating-system-file config))
|
||||||
|
|
||||||
|
(define expression
|
||||||
|
(unattended-upgrade-operating-system-expression config))
|
||||||
|
|
||||||
|
(define arguments
|
||||||
|
(if expression
|
||||||
|
#~(list "-e" (object->string '#$expression))
|
||||||
|
#~(list #$config-file)))
|
||||||
|
|
||||||
(define code
|
(define code
|
||||||
(with-imported-modules (source-module-closure '((guix build utils)
|
(with-imported-modules (source-module-closure '((guix build utils)
|
||||||
(gnu services herd)))
|
(gnu services herd)))
|
||||||
|
@ -333,9 +345,9 @@ (define (alarm-handler . _)
|
||||||
(format #t "~a starting upgrade...~%" (timestamp))
|
(format #t "~a starting upgrade...~%" (timestamp))
|
||||||
(guard (c ((invoke-error? c)
|
(guard (c ((invoke-error? c)
|
||||||
(report-invoke-error c)))
|
(report-invoke-error c)))
|
||||||
(invoke #$(file-append guix "/bin/guix")
|
(apply invoke #$(file-append guix "/bin/guix")
|
||||||
"time-machine" "-C" #$channels
|
"time-machine" "-C" #$channels
|
||||||
"--" "system" "reconfigure" #$config-file)
|
"--" "system" "reconfigure" #$arguments)
|
||||||
|
|
||||||
;; 'guix system delete-generations' fails when there's no
|
;; 'guix system delete-generations' fails when there's no
|
||||||
;; matching generation. Thus, catch 'invoke-error?'.
|
;; matching generation. Thus, catch 'invoke-error?'.
|
||||||
|
|
Loading…
Reference in a new issue