guix-commits
[Top][All Lists]
Advanced

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

01/03: services: unattended-upgrade: Add 'operating-system-file' field.


From: guix-commits
Subject: 01/03: services: unattended-upgrade: Add 'operating-system-file' field.
Date: Mon, 24 Aug 2020 17:25:15 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 0d203eeaa69a42a914a9981449805014ab6b7b77
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Aug 24 14:52:39 2020 +0200

    services: unattended-upgrade: Add 'operating-system-file' field.
    
    * gnu/services/admin.scm 
(<unattended-upgrade-configuration>)[operating-system-file]:
    New field.
    (unattended-upgrade-mcron-jobs): Honor it.
    * doc/guix.texi (Unattended Upgrades): Document it.
---
 doc/guix.texi          | 23 +++++++++++++++++++++++
 gnu/services/admin.scm |  9 +++++++--
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 4264ce5..fed9044 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -15393,6 +15393,29 @@ 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{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.
+
+There are cases, though, where referring to
+@file{/run/current-system/configuration.scm} is not enough, for instance
+because that file refers to extra files (SSH public keys, extra
+configuration files, etc.) @i{via} @code{local-file} and similar
+constructs.  For those cases, we recommend something along these lines:
+
+@lisp
+(unattended-upgrade-configuration
+  (operating-system-file
+    (file-append (local-file "." "config-dir" #:recursive? #t)
+                 "/config.scm")))
+@end lisp
+
+The effect here is to import all of the current directory into the
+store, and to refer to @file{config.scm} within that directory.
+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{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 6ed3de9..61bc17b 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -49,6 +49,7 @@
             unattended-upgrade-service-type
             unattended-upgrade-configuration
             unattended-upgrade-configuration?
+            unattended-upgrade-configuration-operating-system-file
             unattended-upgrade-configuration-channels
             unattended-upgrade-configuration-schedule
             unattended-upgrade-configuration-services-to-restart
@@ -198,6 +199,8 @@ Old log files are removed or compressed according to the 
configuration.")
 (define-record-type* <unattended-upgrade-configuration>
   unattended-upgrade-configuration make-unattended-upgrade-configuration
   unattended-upgrade-configuration?
+  (operating-system-file unattended-upgrade-operating-system-file
+                         (default "/run/current-system/configuration.scm"))
   (schedule             unattended-upgrade-configuration-schedule
                         (default "30 01 * * 0"))
   (channels             unattended-upgrade-configuration-channels
@@ -228,6 +231,9 @@ Old log files are removed or compressed according to the 
configuration.")
   (define expiration
     (unattended-upgrade-system-expiration config))
 
+  (define config-file
+    (unattended-upgrade-operating-system-file config))
+
   (define code
     (with-imported-modules (source-module-closure '((guix build utils)
                                                     (gnu services herd)))
@@ -271,8 +277,7 @@ Old log files are removed or compressed according to the 
configuration.")
                       (report-invoke-error c)))
              (invoke #$(file-append guix "/bin/guix")
                      "time-machine" "-C" #$channels
-                     "--" "system" "reconfigure"
-                     "/run/current-system/configuration.scm")
+                     "--" "system" "reconfigure" #$config-file)
 
              ;; '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]