From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id cEqIHFiSIGTY4wAASxT56A (envelope-from ) for ; Sun, 26 Mar 2023 20:43:36 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id iOpDHFiSIGT/awAAauVa8A (envelope-from ) for ; Sun, 26 Mar 2023 20:43:36 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 0A9DFC12 for ; Sun, 26 Mar 2023 20:43:35 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1679856216; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=hAmUIP/LIqY2w/jJuQJPKfpfUDrYHh3s+t5SlKH1zQM=; b=ny7Jr41Epwmqpj8jr2152FD1gQEbtHx6e78Kt51tgthZ6xB2CP8t2Fp/R22EK0YdiK8+CQ 8AVmuVBfcxFUlWDEAnijTWmAaG4U5XbUOjd77XlZe2TctPFJvrNOAPPxyRjRHEeOw5RuaM cYABgVBM6CKea4HkPwDDUj+EdLMfG/7+lcygRRQRxFxRPmwFRxZgy1wPt75bnUxc4+2nIO CQumBcKd9h5dF8nmq4m9T2SzZy5cpxH+GLk8o0oCC9tuN/3KdmGSB56tMpKuUIG3YzhZOv bMH8afQHcH/lt8yKuvydLxNgscu1r+5vrPiXsZ8wDMSe1JwBlBGsnBYn6/XcjA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1679856216; a=rsa-sha256; cv=none; b=W7azAXmoJ9TAvCneUY8Zztwn2prMvwkxUe30+oG4bm9iVDjKjoJ5hfuPCMIGROfODPDVn8 RVsgr88WNF3D2RnaewUvMqVj76UflSnBCq39bL3/sLZE+s9wwPVn+6udXc9uDsYFYNQkTD vszZocofCXIoO29GcDozhaDujfct+udzBGxpXb7EBDq1GgJbczN10rwJH4ZIQzQj69P5vq GkESVCUUjF4r0edg6yGpC1P0KZ6IhvCBXL612kU7rZCWNYP1G8U0mqunNI1npkFxm6xzvS VojBZ72fdOXazHjonVbbn48jLrbvr6eK+jwM/x7MbGh75WqBs0f7qK75Brvxfw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pgVKd-0007JN-Ea; Sun, 26 Mar 2023 14:43:07 -0400 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 1pgVKZ-0007Ht-NU for guix-patches@gnu.org; Sun, 26 Mar 2023 14:43:03 -0400 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 1pgVKZ-0001Eo-2X for guix-patches@gnu.org; Sun, 26 Mar 2023 14:43:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pgVKY-0003Bk-Uv for guix-patches@gnu.org; Sun, 26 Mar 2023 14:43:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#62298] [PATCH v4 2/5] services: replace bare serializers with (serializer ...) Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 26 Mar 2023 18:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62298 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 62298@debbugs.gnu.org Cc: ludo@gnu.org, Bruno Victal , liliana.prikler@gmail.com, maxim.cournoyer@gmail.com Received: via spool by 62298-submit@debbugs.gnu.org id=B62298.167985616812208 (code B ref 62298); Sun, 26 Mar 2023 18:43:02 +0000 Received: (at 62298) by debbugs.gnu.org; 26 Mar 2023 18:42:48 +0000 Received: from localhost ([127.0.0.1]:45808 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pgVKJ-0003Aq-LE for submit@debbugs.gnu.org; Sun, 26 Mar 2023 14:42:48 -0400 Received: from smtpm2.myservices.hosting ([185.26.105.233]:34018) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pgVKD-0003AP-Gr for 62298@debbugs.gnu.org; Sun, 26 Mar 2023 14:42:42 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpm2.myservices.hosting (Postfix) with ESMTP id E54D020EF2; Sun, 26 Mar 2023 20:42:39 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 662898009A; Sun, 26 Mar 2023 20:42:33 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id aB5U5bRPN60S; Sun, 26 Mar 2023 20:42:32 +0200 (CEST) Received: from guix-nuc.home.arpa (bl9-119-177.dsl.telepac.pt [85.242.119.177]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id 6FE9B80097; Sun, 26 Mar 2023 20:42:32 +0200 (CEST) From: Bruno Victal Date: Sun, 26 Mar 2023 19:41:30 +0100 Message-Id: <5512c499b2954f41f416bd2748d6c1f7687dea68.1679855983.git.mirai@makinata.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: X-Migadu-Queue-Id: 0A9DFC12 X-Spam-Score: 0.97 X-Migadu-Spam-Score: 0.97 X-Migadu-Scanner: scn0.migadu.com List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-TUID: SoT7VPO8DQIq * gnu/home/services/shells.scm (home-zsh-configuration)[environment-variables]: Use (serializer ...). (home-bash-configuration)[aliases, environment-variables]: Ditto. (home-fish-configuration)[abbreviations, aliases, environment-variables]: Ditto. * gnu/services/audio.scm (mpd-configuration)[music-dir, playlist-dir, endpoints] [address, inputs, archive-plugins, input-cache-size, decoders, filters] [playlist-plugins]: Ditto. * gnu/services/linux.scm (fstrim-configuration)[extra-arguments]: Ditto. * gnu/services/security.scm (fail2ban-jail-configuration)[backend, log-encoding] [extra-content]: Ditto. * tests/services/configuration.scm: Update tests. Add test for deprecated bare serializers. --- gnu/home/services/shells.scm | 12 ++++----- gnu/services/audio.scm | 45 ++++++++++++++++---------------- gnu/services/linux.scm | 7 ++--- gnu/services/security.scm | 6 ++--- tests/services/configuration.scm | 11 +++++++- 5 files changed, 46 insertions(+), 35 deletions(-) diff --git a/gnu/home/services/shells.scm b/gnu/home/services/shells.scm index 3326eb37f4..f05f2221d6 100644 --- a/gnu/home/services/shells.scm +++ b/gnu/home/services/shells.scm @@ -133,7 +133,7 @@ (define-configuration home-zsh-configuration (environment-variables (alist '()) "Association list of environment variables to set for the Zsh session." - serialize-posix-env-vars) + (serializer serialize-posix-env-vars)) (zshenv (text-config '()) "List of file-like objects, which will be added to @file{.zshenv}. @@ -334,7 +334,7 @@ (define-configuration home-bash-configuration rules for the @code{home-environment-variables-service-type} apply here (@pxref{Essential Home Services}). The contents of this field will be added after the contents of the @code{bash-profile} field." - serialize-posix-env-vars) + (serializer serialize-posix-env-vars)) (aliases (alist '()) "Association list of aliases to set for the Bash session. The aliases will be @@ -351,7 +351,7 @@ (define-configuration home-bash-configuration @example alias ls=\"ls -alF\" @end example" - bash-serialize-aliases) + (serializer bash-serialize-aliases)) (bash-profile (text-config '()) "List of file-like objects, which will be added to @file{.bash_profile}. @@ -536,19 +536,19 @@ (define-configuration home-fish-configuration (environment-variables (alist '()) "Association list of environment variables to set in Fish." - serialize-fish-env-vars) + (serializer serialize-fish-env-vars)) (aliases (alist '()) "Association list of aliases for Fish, both the key and the value should be a string. An alias is just a simple function that wraps a command, If you want something more akin to @dfn{aliases} in POSIX shells, see the @code{abbreviations} field." - serialize-fish-aliases) + (serializer serialize-fish-aliases)) (abbreviations (alist '()) "Association list of abbreviations for Fish. These are words that, when typed in the shell, will automatically expand to the full text." - serialize-fish-abbreviations)) + (serializer serialize-fish-abbreviations))) (define (fish-files-service config) `(("fish/config.fish" diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm index 4885fb8424..c073b85a32 100644 --- a/gnu/services/audio.scm +++ b/gnu/services/audio.scm @@ -370,7 +370,7 @@ (define-configuration mpd-configuration (music-dir ; TODO: deprecated, remove later maybe-string "The directory to scan for music files." - mpd-serialize-deprecated-field) + (serializer mpd-serialize-deprecated-field)) (playlist-directory maybe-string @@ -379,7 +379,7 @@ (define-configuration mpd-configuration (playlist-dir ; TODO: deprecated, remove later maybe-string "The directory to store playlists." - mpd-serialize-deprecated-field) + (serializer mpd-serialize-deprecated-field)) (db-file maybe-string @@ -405,16 +405,17 @@ (define-configuration mpd-configuration port is used. To use a Unix domain socket, an absolute path or a path starting with @code{~} can be specified here." - (lambda (_ endpoints) - (if (maybe-value-set? endpoints) - (mpd-serialize-list-of-strings "bind_to_address" endpoints) - ""))) + (serializer + (lambda (_ endpoints) + (if (maybe-value-set? endpoints) + (mpd-serialize-list-of-strings "bind_to_address" endpoints) + "")))) (address ; TODO: deprecated, remove later maybe-string "The address that mpd will bind to. To use a Unix domain socket, an absolute path can be specified here." - mpd-serialize-deprecated-field) + (serializer mpd-serialize-deprecated-field)) (database maybe-mpd-plugin @@ -431,29 +432,29 @@ (define-configuration mpd-configuration (inputs (list-of-mpd-plugin '()) "List of MPD input plugin configurations." - (lambda (_ x) - (mpd-serialize-list-of-mpd-plugin "input" x))) + (serializer (lambda (_ x) + (mpd-serialize-list-of-mpd-plugin "input" x)))) (archive-plugins (list-of-mpd-plugin '()) "List of MPD archive plugin configurations." - (lambda (_ x) - (mpd-serialize-list-of-mpd-plugin "archive_plugin" x))) + (serializer (lambda (_ x) + (mpd-serialize-list-of-mpd-plugin "archive_plugin" x)))) (input-cache-size maybe-string "MPD input cache size." - (lambda (_ x) - (if (maybe-value-set? x) - #~(string-append "\ninput_cache {\n" - #$(mpd-serialize-string "size" x) - "}\n") ""))) + (serializer (lambda (_ x) + (if (maybe-value-set? x) + #~(string-append "\ninput_cache {\n" + #$(mpd-serialize-string "size" x) + "}\n") "")))) (decoders (list-of-mpd-plugin '()) "List of MPD decoder plugin configurations." - (lambda (_ x) - (mpd-serialize-list-of-mpd-plugin "decoder" x))) + (serializer (lambda (_ x) + (mpd-serialize-list-of-mpd-plugin "decoder" x)))) (resampler maybe-mpd-plugin @@ -462,8 +463,8 @@ (define-configuration mpd-configuration (filters (list-of-mpd-plugin '()) "List of MPD filter plugin configurations." - (lambda (_ x) - (mpd-serialize-list-of-mpd-plugin "filter" x))) + (serializer (lambda (_ x) + (mpd-serialize-list-of-mpd-plugin "filter" x)))) (outputs (list-of-mpd-plugin-or-output (list (mpd-output))) @@ -473,8 +474,8 @@ (define-configuration mpd-configuration (playlist-plugins (list-of-mpd-plugin '()) "List of MPD playlist plugin configurations." - (lambda (_ x) - (mpd-serialize-list-of-mpd-plugin "playlist_plugin" x))) + (serializer (lambda (_ x) + (mpd-serialize-list-of-mpd-plugin "playlist_plugin" x)))) (extra-options (alist '()) diff --git a/gnu/services/linux.scm b/gnu/services/linux.scm index d085b375a2..229220eeb1 100644 --- a/gnu/services/linux.scm +++ b/gnu/services/linux.scm @@ -213,9 +213,10 @@ (define-configuration fstrim-configuration maybe-list-of-strings "Extra options to append to @command{fstrim} (run @samp{man fstrim} for more information)." - (lambda (_ value) - (if (maybe-value-set? value) - value '()))) + (serializer + (lambda (_ value) + (if (maybe-value-set? value) + value '())))) (prefix fstrim-)) (define (serialize-fstrim-configuration config) diff --git a/gnu/services/security.scm b/gnu/services/security.scm index 8116072920..e750bb468b 100644 --- a/gnu/services/security.scm +++ b/gnu/services/security.scm @@ -200,7 +200,7 @@ (define-configuration fail2ban-jail-configuration "Backend to use to detect changes in the @code{log-path}. The default is 'auto. To consult the defaults of the jail configuration, refer to the @file{/etc/fail2ban/jail.conf} file of the @code{fail2ban} package." - fail2ban-jail-configuration-serialize-backend) + (serializer fail2ban-jail-configuration-serialize-backend)) (max-retry maybe-integer "The number of failures before a host get banned @@ -269,7 +269,7 @@ (define-configuration fail2ban-jail-configuration maybe-symbol "The encoding of the log files handled by the jail. Possible values are: @code{'ascii}, @code{'utf-8} and @code{'auto}." - fail2ban-jail-configuration-serialize-log-encoding) + (serializer fail2ban-jail-configuration-serialize-log-encoding)) (log-path (list-of-strings '()) "The file names of the log files to be monitored.") @@ -280,7 +280,7 @@ (define-configuration fail2ban-jail-configuration (text-config '()) "Extra content for the jail configuration, provided as a list of file-like objects." - serialize-text-config) + (serializer serialize-text-config)) (prefix fail2ban-jail-configuration-)) (define list-of-fail2ban-jail-configurations? diff --git a/tests/services/configuration.scm b/tests/services/configuration.scm index 0392cce927..8ad5907f37 100644 --- a/tests/services/configuration.scm +++ b/tests/services/configuration.scm @@ -82,6 +82,9 @@ (define (custom-number-serializer name value) (format #f "~a = ~a;" name value)) (define-configuration serializable-configuration + (port (number 80) "The port number." (serializer custom-number-serializer))) + +(define-configuration serializable-configuration-deprecated (port (number 80) "The port number." custom-number-serializer)) (test-assert "serialize-configuration" @@ -89,8 +92,14 @@ (define-configuration serializable-configuration (let ((config (serializable-configuration))) (serialize-configuration config serializable-configuration-fields)))) +(test-assert "serialize-configuration [deprecated]" + (gexp? + (let ((config (serializable-configuration-deprecated))) + (serialize-configuration + config serializable-configuration-deprecated-fields)))) + (define-configuration serializable-configuration - (port (number 80) "The port number." custom-number-serializer) + (port (number 80) "The port number." (serializer custom-number-serializer)) (no-serialization)) (test-assert "serialize-configuration with no-serialization" -- 2.39.1