GNU bug report logs - #60497
[PATCH] services: unattended-upgrade: Add 'expression' field.

Previous Next

Package: guix-patches;

Reported by: goodoldpaul <at> autistici.org

Date: Mon, 2 Jan 2023 17:05:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 60497 in the body.
You can then email your comments to 60497 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#60497; Package guix-patches. (Mon, 02 Jan 2023 17:05:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to goodoldpaul <at> autistici.org:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Mon, 02 Jan 2023 17:05:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: goodoldpaul <at> autistici.org
To: guix-patches <at> gnu.org
Subject: [PATCH] services: unattended-upgrade: Add 'expression' field.
Date: Mon, 02 Jan 2023 17:04:04 +0000
Dear Guixers,

I'm sending a patch to add an expression field to the 
unattended-upgrade-configuration record. The main point of this field is 
to be passed to guix system reconfigure -e .

This change should not break any existing configurations but I may have 
missed something.

Thank you for your time and efforts,

giacomo




Information forwarded to guix-patches <at> gnu.org:
bug#60497; Package guix-patches. (Mon, 02 Jan 2023 17:06:01 GMT) Full text and rfc822 format available.

Message #8 received at 60497 <at> debbugs.gnu.org (full text, mbox):

From: Giacomo Leidi <goodoldpaul <at> autistici.org>
To: 60497 <at> debbugs.gnu.org
Cc: Giacomo Leidi <goodoldpaul <at> autistici.org>
Subject: [PATCH] services: unattended-upgrade: Add 'expression' field.
Date: Mon,  2 Jan 2023 18:05:24 +0100
* gnu/services/admin.scm (<unattended-upgrade-configuration>)[expression]:
New field.
(unattended-upgrade-mcron-jobs): Honor it.
* doc/guix.texi (Unattended Upgrades): Document it.
---
 doc/guix.texi          | 12 ++++++++++++
 gnu/services/admin.scm | 15 ++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 5c85680831..cf109cf3d6 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -109,6 +109,7 @@ Copyright @copyright{} 2022 Reily Siegel@*
 Copyright @copyright{} 2022 Simon Streit@*
 Copyright @copyright{} 2022 (@*
 Copyright @copyright{} 2022 John Kehayias@*
+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
@@ -21270,6 +21271,17 @@ This gexp specifies the channels to use for the upgrade
 (@pxref{Channels}).  By default, the tip of the official @code{guix}
 channel is used.
 
+@item @code{expression} (default: @code{#f})
+This field specifies the Guile expression to use for the upgrade
+(@pxref{Invoking guix system}) as a list of symbols.  If no value is provided the
+@code{operating-system-file} field value will be used.
+
+@lisp
+(unattended-upgrade-configuration
+  (expression
+    '(@@ (guix system install) installation-os)))
+@end lisp
+
 @item @code{operating-system-file} (default: @code{"/run/current-system/configuration.scm"})
 This field specifies the operating system configuration file to use.
 The default is to reuse the config file of the current configuration.
diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index 252bedb0bd..ff5ceae47e 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke <at> gnu.org>
 ;;; Copyright © 2016-2022 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2020 Brice Waegeneire <brice <at> waegenei.re>
+;;; Copyright © 2023 Giacomo Leidi <goodoldpaul <at> autistici.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -30,6 +31,7 @@ (define-module (gnu services admin)
   #:use-module (guix packages)
   #:use-module (guix records)
   #:use-module (srfi srfi-1)
+  #:use-module (ice-9 format)
   #:use-module (ice-9 vlist)
   #:export (%default-rotations
             %rotated-files
@@ -57,6 +59,7 @@ (define-module (gnu services admin)
             unattended-upgrade-service-type
             unattended-upgrade-configuration
             unattended-upgrade-configuration?
+            unattended-upgrade-configuration-expression
             unattended-upgrade-configuration-operating-system-file
             unattended-upgrade-configuration-channels
             unattended-upgrade-configuration-schedule
@@ -263,6 +266,8 @@ (define-record-type* <unattended-upgrade-configuration>
   unattended-upgrade-configuration?
   (operating-system-file unattended-upgrade-operating-system-file
                          (default "/run/current-system/configuration.scm"))
+  (expression           unattended-upgrade-expression
+                        (default #f))
   (schedule             unattended-upgrade-configuration-schedule
                         (default "30 01 * * 0"))
   (channels             unattended-upgrade-configuration-channels
@@ -296,6 +301,14 @@ (define expiration
   (define config-file
     (unattended-upgrade-operating-system-file config))
 
+  (define expression
+    (unattended-upgrade-expression config))
+
+  (define reconfigure-args
+    (if expression
+        #~(list "-e" (format #t "~s" expression))
+        #~(list config-file)))
+
   (define code
     (with-imported-modules (source-module-closure '((guix build utils)
                                                     (gnu services herd)))
@@ -335,7 +348,7 @@ (define (alarm-handler . _)
                      (report-invoke-error c)))
             (invoke #$(file-append guix "/bin/guix")
                     "time-machine" "-C" #$channels
-                    "--" "system" "reconfigure" #$config-file)
+                    "--" "system" "reconfigure" #$@reconfigure-args)
 
             ;; 'guix system delete-generations' fails when there's no
             ;; matching generation.  Thus, catch 'invoke-error?'.

base-commit: 7efcf36e3b753a1dba6f8208f3c22d151007eaf0
-- 
2.38.1





Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Tue, 10 Jan 2023 10:12:02 GMT) Full text and rfc822 format available.

Notification sent to goodoldpaul <at> autistici.org:
bug acknowledged by developer. (Tue, 10 Jan 2023 10:12:02 GMT) Full text and rfc822 format available.

Message #13 received at 60497-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Giacomo Leidi <goodoldpaul <at> autistici.org>
Cc: 60497-done <at> debbugs.gnu.org
Subject: Re: bug#60497: [PATCH] services: unattended-upgrade: Add
 'expression' field.
Date: Tue, 10 Jan 2023 11:11:23 +0100
[Message part 1 (text/plain, inline)]
Hi,

Giacomo Leidi <goodoldpaul <at> autistici.org> skribis:

> * gnu/services/admin.scm (<unattended-upgrade-configuration>)[expression]:
> New field.
> (unattended-upgrade-mcron-jobs): Honor it.
> * doc/guix.texi (Unattended Upgrades): Document it.

Nice!  I made the cosmetic changes below to improve consistency.

BTW, previously it had:

     (if expression
         #~(list "-e" (format #t "~s" expression))
         …)

but ‘expression’ is unbound within that gexp (missing #$ somewhere).

Thanks,
Ludo’.

[Message part 2 (text/x-patch, inline)]
diff --git a/doc/guix.texi b/doc/guix.texi
index 78d1dd8b2a..cda940b1fa 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@*
@@ -21340,17 +21340,6 @@ This gexp specifies the channels to use for the upgrade
 (@pxref{Channels}).  By default, the tip of the official @code{guix}
 channel is used.
 
-@item @code{expression} (default: @code{#f})
-This field specifies the Guile expression to use for the upgrade
-(@pxref{Invoking guix system}) as a list of symbols.  If no value is provided the
-@code{operating-system-file} field value will be used.
-
-@lisp
-(unattended-upgrade-configuration
-  (expression
-    '(@@ (guix system install) installation-os)))
-@end lisp
-
 @item @code{operating-system-file} (default: @code{"/run/current-system/configuration.scm"})
 This field specifies the operating system configuration file to use.
 The default is to reuse the config file of the current configuration.
@@ -21374,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 ff5ceae47e..a864da25e9 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -1,6 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke <at> gnu.org>
-;;; Copyright © 2016-2022 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2016-2023 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2020 Brice Waegeneire <brice <at> waegenei.re>
 ;;; Copyright © 2023 Giacomo Leidi <goodoldpaul <at> autistici.org>
 ;;;
@@ -59,8 +59,8 @@ (define-module (gnu services admin)
             unattended-upgrade-service-type
             unattended-upgrade-configuration
             unattended-upgrade-configuration?
-            unattended-upgrade-configuration-expression
             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
@@ -266,8 +266,8 @@ (define-record-type* <unattended-upgrade-configuration>
   unattended-upgrade-configuration?
   (operating-system-file unattended-upgrade-operating-system-file
                          (default "/run/current-system/configuration.scm"))
-  (expression           unattended-upgrade-expression
-                        (default #f))
+  (operating-system-expression unattended-upgrade-operating-system-expression
+                               (default #f))
   (schedule             unattended-upgrade-configuration-schedule
                         (default "30 01 * * 0"))
   (channels             unattended-upgrade-configuration-channels
@@ -302,11 +302,11 @@ (define config-file
     (unattended-upgrade-operating-system-file config))
 
   (define expression
-    (unattended-upgrade-expression config))
+    (unattended-upgrade-operating-system-expression config))
 
-  (define reconfigure-args
+  (define arguments
     (if expression
-        #~(list "-e" (format #t "~s" expression))
+        #~(list "-e" (object->string '#$expression))
         #~(list config-file)))
 
   (define code
@@ -348,7 +348,7 @@ (define (alarm-handler . _)
                      (report-invoke-error c)))
             (invoke #$(file-append guix "/bin/guix")
                     "time-machine" "-C" #$channels
-                    "--" "system" "reconfigure" #$@reconfigure-args)
+                    "--" "system" "reconfigure" #$@arguments)
 
             ;; 'guix system delete-generations' fails when there's no
             ;; matching generation.  Thus, catch 'invoke-error?'.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 07 Feb 2023 12:24:12 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 128 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.