[PATCH] services: unattended-upgrade: Add 'search-paths' field.

DoneSubmitted by Lars-Dominik Braun.
Details
2 participants
  • Lars-Dominik Braun
  • Ludovic Courtès
Owner
unassigned
Severity
normal
L
L
Lars-Dominik Braun wrote on 27 Nov 2020 09:46
(address . guix-patches@gnu.org)
20201127084632.GA3077@zpidnp36
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
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(-)

Toggle diff (60 lines)
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
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(-)

Toggle diff (32 lines)
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
-----BEGIN PGP SIGNATURE-----

iQGzBAABCgAdFiEEyk+M9DfXR4/aBV/UQhN3ARo3hEYFAl/AvOUACgkQQhN3ARo3
hEbZmAwAtH/CF1SSg2K4qWunWdxpsErzh+qVcy+kulNVsS2HfLlTmWqYy4fhcTEM
JCeunyxaew/juEjtRsyQaj2muNlyrMtMkaDU/hK1cepcfHUx9VyM86Cc0hQC9kxu
gnTFIgGiFOLP09SiJsJAJe56wRdO1leYPzrFwG4Jgohn2MUxUgFbCDcD2O1wx7L5
OHkSfZfBocTMD6yUNMs13nVqy+bEJO47NHL4/J9rnwq4aXjd9rrtM1yOsCsW3/Vx
ghLmQG9Sj81IOKfvB3PHexAj7Ldp5OuLAcL/yz9BIINTXviJtVf3ieQ+BasPWmvu
yUUJp6CYtFAAVwMNQOlNg5a0IU/unJEeLtupuqSBeMhxEBMHgtafsa4YWzqnjNA7
EqqmtbC6n/Y3FudQiYNWVT8rpxV8bzfc2IjPVWeY/yXhCtYOrnFBovQcuPZ81vdZ
lau9GAx7AvC7fIAsR0NxZJKG2Kb8Q8ZrqjPOQ2lXl81XyeZO6PVI2wQej9uJ3hbe
HeMoxZpb
=qJ/n
-----END PGP SIGNATURE-----


L
L
Ludovic Courtès wrote on 28 Nov 2020 11:33
(name . Lars-Dominik Braun)(address . ldb@leibniz-psychology.org)(address . 44900@debbugs.gnu.org)
87eekdrcrw.fsf@gnu.org
Hi,

Lars-Dominik Braun <ldb@leibniz-psychology.org> skribis:

Toggle quote (7 lines)
> 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?

Did you see (info "(guix) Unattended Upgrades"):

There are cases, though, where referring to
‘/run/current-system/configuration.scm’ is not enough, for
instance because that file refers to extra files (SSH public
keys, extra configuration files, etc.) via ‘local-file’ and
similar constructs. For those cases, we recommend something
along these lines:

(unattended-upgrade-configuration
(operating-system-file
(file-append (local-file "." "config-dir" #:recursive? #t)
"/config.scm")))

The effect here is to import all of the current directory into
the store, and to refer to ‘config.scm’ within that directory.
Therefore, uses of ‘local-file’ within ‘config.scm’ will work
as expected. *Note G-Expressions::, for information about
‘local-file’ and ‘file-append’.

I can see several options:

1. Use the trick above and add (say):

(add-to-load-path (dirname (current-filename)))

in your config file. Not pretty.

2. Turn your modules into a channel. Nice because there’s no need for
a special case, modules are automatically updated at each upgrade,
etc., but OTOH requires more paperwork.

3. What you propose. Easy to use but a bit low-level and users could
be tempted to pass local file names instead of using ‘local-file’,
in which case the process becomes more brittle (depends on things
outside the store).

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

I prefer being explicit here and keep ‘unattended-upgrade-configuration’
self-contained (/etc/guix/channels.scm could be modified behind our
back).

WDYT?

Thanks,
Ludo’.
L
L
Lars-Dominik Braun wrote on 30 Nov 2020 09:18
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 44900@debbugs.gnu.org)
20201130081842.GB6084@zpidnp36
Hi Ludo,

Toggle quote (6 lines)
> Did you see (info "(guix) Unattended Upgrades"):
> 1. Use the trick above and add (say):
>
> (add-to-load-path (dirname (current-filename)))
>
> in your config file. Not pretty.
yes, saw it, but I wasn’t sure how to load modules from that directory. And I
agree, it’s not pretty, but probably better than option 3, because everything
is in the store.

Toggle quote (3 lines)
> 2. Turn your modules into a channel. Nice because there’s no need for
> a special case, modules are automatically updated at each upgrade,
> etc., but OTOH requires more paperwork.
I feel this might be the best option and I’ll give it a try.

Toggle quote (3 lines)
> I prefer being explicit here and keep ‘unattended-upgrade-configuration’
> self-contained (/etc/guix/channels.scm could be modified behind our
> back).
Okay, I can see that, but I’d like to use the same list of channels in that
service and channels.scm. Since creating an etc-service for
/etc/guix/channels.scm does not work, I was left with the other option, i.e.
using that file for unattended upgrades. Are there any other options?

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
-----BEGIN PGP SIGNATURE-----

iQGzBAABCgAdFiEEyk+M9DfXR4/aBV/UQhN3ARo3hEYFAl/Eqt0ACgkQQhN3ARo3
hEa39QwAszMOtSGtl9gyUi57r+CT+Y3Jwkq2E66EoQrillDP+5rky9InZ/zB6ZEa
Ru18pO9I4Rk/kK6KFyuVhRmolNqQ+cJG0Q704xepzrV5ttvyjAe+9sLBWYe8ctTB
zCGzXD8ajDvGRW6A7EbPpnlokxRT+CYK3GqxzqsmF8w5rXn6y1H8013vZr7YZJQ1
6qN+cFVFzboxdp3+0ys8twce8RWy3eIQp8+cJ1LEP9DMAcAPNpuhnaIg+RFX2bnK
dE1bmQ/W1z6gq18Pf5t287xtIGAXwiIKkOJdfHGtJ8KiHtcm8cd2E8j2zoAhgNkH
CHUif/2nABD0OEa05fKX1ikXfusqbpqa+22KPsrPcSfgDCyGUb94V2IBJfCjHjb9
0Qgmw8beRjzR/mnxA6m0lmPesPqX9CGJvw3OWA7pNok3OrHrlI38nCx12TCPIwUk
1nAITJSPMvYvGfsbak7/mCnGZfTVu0BAMliqpfgGW3FgBnJYOGys4kSJKFRa1DGv
loFxP/Wc
=3Ix1
-----END PGP SIGNATURE-----


L
L
Ludovic Courtès wrote on 30 Nov 2020 14:54
(name . Lars-Dominik Braun)(address . ldb@leibniz-psychology.org)(address . 44900@debbugs.gnu.org)
87k0u3lzkt.fsf@gnu.org
Hi!

Lars-Dominik Braun <ldb@leibniz-psychology.org> skribis:

Toggle quote (8 lines)
>> I prefer being explicit here and keep ‘unattended-upgrade-configuration’
>> self-contained (/etc/guix/channels.scm could be modified behind our
>> back).
> Okay, I can see that, but I’d like to use the same list of channels in that
> service and channels.scm. Since creating an etc-service for
> /etc/guix/channels.scm does not work, I was left with the other option, i.e.
> using that file for unattended upgrades. Are there any other options?

I’d say that specifying the ‘channels’ field of
‘unattended-upgrade-configuration’ gives you that, no?

Also, what doesn’t it work to populate /etc/guix/channels.scm via
‘etc-service-type’?

Thanks,
Ludo’.
L
L
Lars-Dominik Braun wrote on 3 Dec 2020 09:36
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 44900@debbugs.gnu.org)
20201203083646.GA3154@zpidnp36
Hi,

Toggle quote (6 lines)
> > Okay, I can see that, but I’d like to use the same list of channels in that
> > service and channels.scm. Since creating an etc-service for
> > /etc/guix/channels.scm does not work, I was left with the other option, i.e.
> > using that file for unattended upgrades. Are there any other options?
> I’d say that specifying the ‘channels’ field of
> ‘unattended-upgrade-configuration’ gives you that, no?
no, /etc/guix/channels.scm also functions as a default channel list for every
users’ `guix pull`, which I also want to have.

Toggle quote (2 lines)
> Also, what doesn’t it work to populate /etc/guix/channels.scm via
> ‘etc-service-type’?
This snippet:

---snip---
(simple-service 'guix-channels etc-service-type
(list `("guix/channels.scm" , (scheme-file "channels.scm" %guix-channels))))
---snap---

Causes this error when reconfiguring:

---snip---
activating system...
The following derivation will be built:
/gnu/store/qqp3vz7r6i6fa7wckzdxs1613gvww4b6-switch-to-system.scm.drv

building /gnu/store/qqp3vz7r6i6fa7wckzdxs1613gvww4b6-switch-to-system.scm.drv...
making '/gnu/store/ykfn25vpvgmjkq4l8xygs7fwabgkgp2s-system' the current system...
setting up setuid programs in '/run/setuid-programs'...
populating /etc from /gnu/store/mdpbph8cpgwydy3hwfq0q6sk44bfbk93-etc...
guix system: error: symlink: File exists: "/etc/guix"
---snap---

/gnu/store/mdpbph8cpgwydy3hwfq0q6sk44bfbk93-etc looks correct to me, i.e. it
has a guix subdirectory with a correct channels.scm file in it.

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
-----BEGIN PGP SIGNATURE-----

iQGzBAABCgAdFiEEyk+M9DfXR4/aBV/UQhN3ARo3hEYFAl/Io5sACgkQQhN3ARo3
hEYjewv+L6aGixZ8r/mmR4e+iuUsRAnELqyPwlIGIodryuCRPXsTvBbhRWw8Mzgv
HrzCNMdaZ8HS4J0kzJeBY+peG5EBriWnEJSTcv7U0CcvrqVtAwNgZXCc7lMU6Sz2
maAiUlBx04E1EUkkmSCylS9USGl+kArcy1pJb4WTHVWSBRNV0YtdN/PCNNXC7ZKA
rUq/7jSiUfj+DNan60TUkIRK3HdkAbye1RAtyw4vNXK+L/1WsBZUiUjUa6VN5ENS
VL0FCpcdSQprMx/1be5ymfoxcccDsEmzxQ4Rl4z/sDdKpkoy6PkM2pAbYkscprwh
vwPx11l/6P8rV1CWmKqlxCy4Dhge5GfPZZxgdCxB0K7JCszirpOB6lt2teoFeHgn
/0dIZMpCU35+GL3Jq1SBNnjCXnwVgSQ4vnsvt+Zhyg0bImaoegcsnKpdX73TcWFT
plJ1z3R3bZf2Ed6GY85pUlZTArnPFqwTQduQswyKoQ76pXnkiIEVmT4AtwNe1HGX
R+B7Pd2S
=7eEA
-----END PGP SIGNATURE-----


L
L
Ludovic Courtès wrote on 7 Dec 2020 21:58
(name . Lars-Dominik Braun)(address . ldb@leibniz-psychology.org)(address . 44900@debbugs.gnu.org)
87lfe9z62g.fsf@gnu.org
Hi,

Lars-Dominik Braun <ldb@leibniz-psychology.org> skribis:

Toggle quote (24 lines)
> This snippet:
>
> ---snip---
> (simple-service 'guix-channels etc-service-type
> (list `("guix/channels.scm" , (scheme-file "channels.scm" %guix-channels))))
> ---snap---
>
> Causes this error when reconfiguring:
>
> ---snip---
> activating system...
> The following derivation will be built:
> /gnu/store/qqp3vz7r6i6fa7wckzdxs1613gvww4b6-switch-to-system.scm.drv
>
> building /gnu/store/qqp3vz7r6i6fa7wckzdxs1613gvww4b6-switch-to-system.scm.drv...
> making '/gnu/store/ykfn25vpvgmjkq4l8xygs7fwabgkgp2s-system' the current system...
> setting up setuid programs in '/run/setuid-programs'...
> populating /etc from /gnu/store/mdpbph8cpgwydy3hwfq0q6sk44bfbk93-etc...
> guix system: error: symlink: File exists: "/etc/guix"
> ---snap---
>
> /gnu/store/mdpbph8cpgwydy3hwfq0q6sk44bfbk93-etc looks correct to me, i.e. it
> has a guix subdirectory with a correct channels.scm file in it.

Yes, somebody else reported that problem recently (and proposed a
solution I think, was it on guix-devel?). The issue here is that
/etc/guix is also partly stateful, so there’s ‘activation-service-type’,
‘etc-service-type’, and manual changes say to /etc/guix/machines.scm,
are conflicting.

Ludo’.
L
L
Lars-Dominik Braun wrote on 15 Dec 2020 09:17
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 44900@debbugs.gnu.org)
20201215081713.GA2831@zpidnp36
Hi,

Toggle quote (4 lines)
> > 2. Turn your modules into a channel. Nice because there’s no need for
> > a special case, modules are automatically updated at each upgrade,
> > etc., but OTOH requires more paperwork.
> I feel this might be the best option and I’ll give it a try.
I’ve implemented this now and it is indeed a very good solution. For anyone
stumbling on this issue, I’m using the following service configuration:

---snip---
(unattended-upgrade-configuration
(channels #~(cons* (channel
(name 'psychnotebook-deploy)
(introduction
(make-channel-introduction
"02ae8f9f647ab9650bc9211e728841931f25792c"
(openpgp-fingerprint
"CA4F 8CF4 37D7 478F DA05 5FD4 4213 7701 1A37 8446"))))
%default-channels))
(operating-system-file
(scheme-file "config.scm"
#~(@ (zpid machines yamunanagar os) yamunanagar-os)))
(schedule "55 13 * * *")
(services-to-restart '(nginx ntpd guix-publish ssh-daemon mcron)))
---snap---

So, I’m fine with closing this as wontfix.

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
-----BEGIN PGP SIGNATURE-----

iQGzBAABCgAdFiEEyk+M9DfXR4/aBV/UQhN3ARo3hEYFAl/YcQUACgkQQhN3ARo3
hEbkMwv/YtmPVB9zreWucdYoQpx51pSpTjXJuQmOQGCvKzo3P5Lfl6KqY/eLxmxX
iOEwGoE7tCQ+2Kk22EdhVmNWJjGTbCaiPpSfOn+SlZ0GDEuihgIAUHKgu3nFjW7c
zbe0xyTe0M+0FSx4PYLSMlQ9TfQG0KXvtUTqZeNXMDhRR9Sohgx+8OXnTu3PBuO9
QuJP9rd8rN8EDDKBuo9izms4ytgerD8mh5eA00byEeXZxtRh3KK6XZagAjWbLAOD
Hg9vfJDXfSZ8Gxpb6zWXTtZNxHqSuwiidFm3ZYIJNCb4gj9a05Tqg8f7OuZGnJVd
AGjUfORyISDu5jVxhZAGUbRlDTRX+JoswXtZ+QuNO2RjtZdp7hD6BBwnsRtIZ33J
mpraBotDMw4ThDODHuuera51wy0ojxl3k1CKDsrkhPhRoL2T/vFabkCi1E68tgMg
dRBxONwEEKF5zU2Di8D4Rv/cmAotDY2uSOrduy97NlWIugR72iNv2vRvpbbYPp9g
zBUV8e2e
=rIc7
-----END PGP SIGNATURE-----


L
L
Ludovic Courtès wrote on 23 Dec 2020 16:57
control message for bug #44900
(address . control@debbugs.gnu.org)
87h7ocwm55.fsf@gnu.org
tags 44900 wontfix
close 44900
quit
?
Your comment

This issue is archived.

To comment on this conversation send email to 44900@debbugs.gnu.org