unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Giacomo Leidi via Guix-patches via <guix-patches@gnu.org>
To: 60497@debbugs.gnu.org
Cc: Giacomo Leidi <goodoldpaul@autistici.org>
Subject: [bug#60497] [PATCH] services: unattended-upgrade: Add 'expression' field.
Date: Mon,  2 Jan 2023 18:05:24 +0100	[thread overview]
Message-ID: <20230102170524.32115-1-goodoldpaul@autistici.org> (raw)
In-Reply-To: <868271b51416d65038128233f85f88f8@autistici.org>

* 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@gnu.org>
 ;;; Copyright © 2016-2022 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.
 ;;;
@@ -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	other threads:[~2023-01-02 17:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-02 17:04 [bug#60497] [PATCH] services: unattended-upgrade: Add 'expression' field goodoldpaul--- via Guix-patches via
2023-01-02 17:05 ` Giacomo Leidi via Guix-patches via [this message]
2023-01-10 10:11   ` bug#60497: " Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230102170524.32115-1-goodoldpaul@autistici.org \
    --to=guix-patches@gnu.org \
    --cc=60497@debbugs.gnu.org \
    --cc=goodoldpaul@autistici.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).