unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars-Dominik Braun <ldb@leibniz-psychology.org>
To: 44900@debbugs.gnu.org
Subject: [bug#44900] [PATCH] services: unattended-upgrade: Add 'search-paths' field.
Date: Fri, 27 Nov 2020 09:46:32 +0100	[thread overview]
Message-ID: <20201127084632.GA3077@zpidnp36> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 883 bytes --]

Hi,

I’m using a modular machine configuration, i.e. the scheme file returning the
operating system definition imports several other custom modules with service
definitions etc in the same directory. This does not work well with unattended
upgrades. The attached patch allows adding search paths to the unattended
upgrade service. I’m not sure this is the best solution though. Maybe the
preferred way to add these modules is to a custom channel?

The second patch changes the default channels to #f, i.e. the system default
(/etc/guix/channels.scm), which feels more natural to me.

Cheers,
Lars

-- 
Lars-Dominik Braun
Wissenschaftlicher Mitarbeiter/Research Associate

www.leibniz-psychology.org
ZPID - Leibniz-Institut für Psychologie /
ZPID - Leibniz Institute for Psychology
Universitätsring 15
D-54296 Trier - Germany
Tel.: +49–651–201-4964

[-- Attachment #1.2: 0001-services-unattended-upgrade-Add-search-paths-field.patch --]
[-- Type: text/x-diff, Size: 3687 bytes --]

From d5dd0da8976211a0d0b77663ae8f8f945e92a7a1 Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <ldb@leibniz-psychology.org>
Date: Fri, 27 Nov 2020 09:32:41 +0100
Subject: [PATCH 1/2] services: unattended-upgrade: Add 'search-paths' field.

* gnu/services/admin.scm (<unattended-upgrade-configuration>)[search-paths]:
New field.
(unattended-upgrade-mcron-jobs): Honor it.
* doc/guix.texi (Unattended Upgrades): Document it.
---
 doc/guix.texi          |  4 ++++
 gnu/services/admin.scm | 18 +++++++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 32b91272cf..7f42fe8867 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -17063,6 +17063,10 @@ 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{search-paths} (default: @code{'()})
+This list specifies the extra search paths used.  By default, no search paths
+are added.
+
 @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 b34b990f32..87cf76c57f 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -205,6 +205,8 @@ Old log files are removed or compressed according to the configuration.")
                         (default "30 01 * * 0"))
   (channels             unattended-upgrade-configuration-channels
                         (default #~%default-channels))
+  (search-paths         unattended-upgrade-configuration-search-paths
+                        (default '()))
   (services-to-restart  unattended-upgrade-configuration-services-to-restart
                         (default '(mcron)))
   (system-expiration    unattended-upgrade-system-expiration
@@ -219,8 +221,8 @@ Old log files are removed or compressed according to the configuration.")
 
 (define (unattended-upgrade-mcron-jobs config)
   (define channels
-    (scheme-file "channels.scm"
-                 (unattended-upgrade-configuration-channels config)))
+    (let ((c (unattended-upgrade-configuration-channels config)))
+      (if c (scheme-file "channels.scm" c) #f)))
 
   (define log
     (unattended-upgrade-configuration-log-file config))
@@ -271,9 +273,15 @@ 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)
+	    (let* ((channel #$(if channels #~(list "-C" #$channels) (quote '())))
+                   (search-paths (quote #$(unattended-upgrade-configuration-search-paths config)))
+                   (search-path-args (apply append (map (lambda (x) (list "-L" x)) search-paths)))
+                   (command (append (list #$(file-append guix "/bin/guix") "time-machine")
+                                    channel
+                                    (list "--" "system" "reconfigure")
+                                    search-path-args
+                                    (list #$config-file))))
+              (apply invoke command))
 
             ;; 'guix system delete-generations' fails when there's no
             ;; matching generation.  Thus, catch 'invoke-error?'.
-- 
2.25.1


[-- Attachment #1.3: 0002-services-unattended-upgrade-Change-default-for-chann.patch --]
[-- Type: text/x-diff, Size: 2044 bytes --]

From b425b012533de4a460cf22a14a4fcfbed78c0c2b Mon Sep 17 00:00:00 2001
From: Lars-Dominik Braun <ldb@leibniz-psychology.org>
Date: Fri, 27 Nov 2020 09:42:11 +0100
Subject: [PATCH 2/2] services: unattended-upgrade: Change default for
 'channels' field.

* gnu/services/admin.scm (<unattended-upgrade-configuration>)[channels]:
Default to #f.
* doc/guix.texi (Unattended Upgrades): Document it.
---
 doc/guix.texi          | 5 ++---
 gnu/services/admin.scm | 2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 7f42fe8867..5168d7d840 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -17058,10 +17058,9 @@ This is the schedule of upgrades, expressed as a gexp containing an
 mcron job schedule (@pxref{Guile Syntax, mcron job specifications,,
 mcron, GNU@tie{}mcron}).
 
-@item @code{channels} (default: @code{#~%default-channels})
+@item @code{channels} (default: @code{#f})
 This gexp specifies the channels to use for the upgrade
-(@pxref{Channels}).  By default, the tip of the official @code{guix}
-channel is used.
+(@pxref{Channels}).  By default, the system’s default is used.
 
 @item @code{search-paths} (default: @code{'()})
 This list specifies the extra search paths used.  By default, no search paths
diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index 87cf76c57f..a1c4abd3e2 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -204,7 +204,7 @@ Old log files are removed or compressed according to the configuration.")
   (schedule             unattended-upgrade-configuration-schedule
                         (default "30 01 * * 0"))
   (channels             unattended-upgrade-configuration-channels
-                        (default #~%default-channels))
+                        (default #f))
   (search-paths         unattended-upgrade-configuration-search-paths
                         (default '()))
   (services-to-restart  unattended-upgrade-configuration-services-to-restart
-- 
2.25.1


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

             reply	other threads:[~2020-11-27  8:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-27  8:46 Lars-Dominik Braun [this message]
2020-11-28 10:33 ` [bug#44900] [PATCH] services: unattended-upgrade: Add 'search-paths' field Ludovic Courtès
2020-11-30  8:18   ` Lars-Dominik Braun
2020-11-30 13:54     ` Ludovic Courtès
2020-12-03  8:36       ` Lars-Dominik Braun
2020-12-07 20:58         ` Ludovic Courtès
2020-12-15  8:17     ` Lars-Dominik Braun

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=20201127084632.GA3077@zpidnp36 \
    --to=ldb@leibniz-psychology.org \
    --cc=44900@debbugs.gnu.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).