From patchwork Tue Jan 10 10:11:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 46012 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 8E9F027BBEB; Tue, 10 Jan 2023 10:21:19 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id EFF6527BBE9 for ; Tue, 10 Jan 2023 10:21:17 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFBbz-0008FS-9B; Tue, 10 Jan 2023 05:12:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFBbv-0008Da-LD for guix-patches@gnu.org; Tue, 10 Jan 2023 05:12:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFBbu-00014q-VK for guix-patches@gnu.org; Tue, 10 Jan 2023 05:12:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pFBbu-0005zY-QP for guix-patches@gnu.org; Tue, 10 Jan 2023 05:12:02 -0500 Subject: bug#60497: [PATCH] services: unattended-upgrade: Add 'expression' field. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-To: guix-patches@gnu.org Resent-Date: Tue, 10 Jan 2023 10:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 60497 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Giacomo Leidi Cc: 60497-done@debbugs.gnu.org Mail-Followup-To: 60497@debbugs.gnu.org, ludo@gnu.org, goodoldpaul@autistici.org Received: via spool by 60497-done@debbugs.gnu.org id=D60497.167334549522960 (code D ref 60497); Tue, 10 Jan 2023 10:12:02 +0000 Received: (at 60497-done) by debbugs.gnu.org; 10 Jan 2023 10:11:35 +0000 Received: from localhost ([127.0.0.1]:38851 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFBbS-0005yC-TM for submit@debbugs.gnu.org; Tue, 10 Jan 2023 05:11:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59978) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFBbR-0005xy-VS for 60497-done@debbugs.gnu.org; Tue, 10 Jan 2023 05:11:34 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFBbL-0000u6-O3; Tue, 10 Jan 2023 05:11:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=l/aT5gDHLjwrFtJQtRLg1PFvxnmZRq202pEhJG3XbpY=; b=RBNaMkZPiVe0cFhgwwdp YDaH1QnzGa19umvFWmoDy8OCDNgGT+NSJIqYTuS8a1oS1Iyk191+h7rU1pjr0joNa6xZpSVU/4aJF oDxxcoWGI2peVogpCmm0skYJyXZySME4wuZx1yQ5U8mScSgWk6mZioS/u9HFIYREB5rG5k5Fi9c0e dGVUihrQ3UlxXj1PF78fPmPWDgRaFvk0g2QC65foJTEnv+tTKS3dGji2vY28BvF3K+cw99gVb5KFm VmwDvPDqzfCrzJH8TFBAEI3NNquxZu8IPcdhXAeTAVmvyWXpRgfdRq8VP0gn4qvK6sjVyk6jZ0dDR 18dVcndIMFvVnQ==; Received: from [193.50.110.246] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFBbJ-0007hI-UU; Tue, 10 Jan 2023 05:11:26 -0500 From: Ludovic =?utf-8?q?Court=C3=A8s?= References: <868271b51416d65038128233f85f88f8@autistici.org> <20230102170524.32115-1-goodoldpaul@autistici.org> Date: Tue, 10 Jan 2023 11:11:23 +0100 In-Reply-To: <20230102170524.32115-1-goodoldpaul@autistici.org> (Giacomo Leidi's message of "Mon, 2 Jan 2023 18:05:24 +0100") Message-ID: <87pmbmog1g.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Hi, Giacomo Leidi skribis: > * gnu/services/admin.scm ()[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’. 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 -;;; Copyright © 2016-2022 Ludovic Courtès +;;; Copyright © 2016-2023 Ludovic Courtès ;;; Copyright © 2020 Brice Waegeneire ;;; Copyright © 2023 Giacomo Leidi ;;; @@ -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? (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?'.