guix-commits
[Top][All Lists]
Advanced

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

05/09: services: unattended-upgrade: Add 'operating-system-expression' f


From: guix-commits
Subject: 05/09: services: unattended-upgrade: Add 'operating-system-expression' field.
Date: Tue, 10 Jan 2023 05:51:19 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit 5f63811032dab5c04c397e043cc7290cb3d51ee0
Author: Giacomo Leidi <goodoldpaul@autistici.org>
AuthorDate: Mon Jan 2 18:05:24 2023 +0100

    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>
---
 doc/guix.texi          | 14 +++++++++++++-
 gnu/services/admin.scm | 20 ++++++++++++++++----
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 11a4ca18fb..cd0f561f71 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -22,7 +22,7 @@
 @set SUBSTITUTE-URLS https://@value{SUBSTITUTE-SERVER-1} 
https://@value{SUBSTITUTE-SERVER-2}
 
 @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 Nikita Karetnikov@*
 Copyright @copyright{} 2014, 2015, 2016 Alex Kost@*
@@ -110,6 +110,7 @@ Copyright @copyright{} 2022 Simon Streit@*
 Copyright @copyright{} 2022 (@*
 Copyright @copyright{} 2022 John Kehayias@*
 Copyright @copyright{} 2022 Ivan Vilata-i-Balaguer@*
+Copyright @copyright{} 2023 Giacomo Leidi@*
 
 Permission is granted to copy, distribute and/or modify this document
 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
 @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)})
 This field specifies the Shepherd services to restart when the upgrade
 completes.
diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index 252bedb0bd..1c10cfb1f6 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -1,7 +1,8 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; 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 © 2023 Giacomo Leidi <goodoldpaul@autistici.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -58,6 +59,7 @@
             unattended-upgrade-configuration
             unattended-upgrade-configuration?
             unattended-upgrade-configuration-operating-system-file
+            unattended-upgrade-configuration-operating-system-expression
             unattended-upgrade-configuration-channels
             unattended-upgrade-configuration-schedule
             unattended-upgrade-configuration-services-to-restart
@@ -263,6 +265,8 @@ Old log files are removed or compressed according to the 
configuration.")
   unattended-upgrade-configuration?
   (operating-system-file unattended-upgrade-operating-system-file
                          (default "/run/current-system/configuration.scm"))
+  (operating-system-expression unattended-upgrade-operating-system-expression
+                               (default #f))
   (schedule             unattended-upgrade-configuration-schedule
                         (default "30 01 * * 0"))
   (channels             unattended-upgrade-configuration-channels
@@ -296,6 +300,14 @@ Old log files are removed or compressed according to the 
configuration.")
   (define config-file
     (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
     (with-imported-modules (source-module-closure '((guix build utils)
                                                     (gnu services herd)))
@@ -333,9 +345,9 @@ Old log files are removed or compressed according to the 
configuration.")
           (format #t "~a starting upgrade...~%" (timestamp))
           (guard (c ((invoke-error? c)
                      (report-invoke-error c)))
-            (invoke #$(file-append guix "/bin/guix")
-                    "time-machine" "-C" #$channels
-                    "--" "system" "reconfigure" #$config-file)
+            (apply invoke #$(file-append guix "/bin/guix")
+                   "time-machine" "-C" #$channels
+                   "--" "system" "reconfigure" #$arguments)
 
             ;; 'guix system delete-generations' fails when there's no
             ;; matching generation.  Thus, catch 'invoke-error?'.



reply via email to

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