From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id YFwuH5MnBmNFjAAAbAwnHQ (envelope-from ) for ; Wed, 24 Aug 2022 15:28:51 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 8GIvHpMnBmMvfgEAG6o9tA (envelope-from ) for ; Wed, 24 Aug 2022 15:28:51 +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 1858428A7A for ; Wed, 24 Aug 2022 15:28:51 +0200 (CEST) Received: from localhost ([::1]:47268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQqR8-0004Uq-7N for larch@yhetil.org; Wed, 24 Aug 2022 09:28:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQphr-0005Pv-Jw for bug-guix@gnu.org; Wed, 24 Aug 2022 08:42:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56179) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQphr-0000mt-6z for bug-guix@gnu.org; Wed, 24 Aug 2022 08:42:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oQphr-00083Q-38 for bug-guix@gnu.org; Wed, 24 Aug 2022 08:42:03 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#56799: [PATCH 4/5] services: Use the new maybe/unset API. Resent-From: Attila Lendvai Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Wed, 24 Aug 2022 12:42:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56799 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 56799@debbugs.gnu.org Cc: Attila Lendvai Received: via spool by 56799-submit@debbugs.gnu.org id=B56799.166134488430880 (code B ref 56799); Wed, 24 Aug 2022 12:42:03 +0000 Received: (at 56799) by debbugs.gnu.org; 24 Aug 2022 12:41:24 +0000 Received: from localhost ([127.0.0.1]:45922 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQphD-00081z-BA for submit@debbugs.gnu.org; Wed, 24 Aug 2022 08:41:23 -0400 Received: from mail-ed1-f53.google.com ([209.85.208.53]:36568) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQphA-00081Y-IU for 56799@debbugs.gnu.org; Wed, 24 Aug 2022 08:41:21 -0400 Received: by mail-ed1-f53.google.com with SMTP id w10so9730410edc.3 for <56799@debbugs.gnu.org>; Wed, 24 Aug 2022 05:41:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc; bh=0Fwrp6nxrXLxGj0dPcOpp3eHE7TtqCEnW5Mdr8aBjEk=; b=YSfoAIV2gcCORWlLrpxoGAmkcsbk60WnbY9TUVI832v4dPuFFkC1lsmOQMaZkLsf6w GdAAinBVNN0H7VJw+0QKRuDUeGdVGRaj+7OPz32mejYIo0tK67hauIEO6xLiEmUy9XmC CCmDKtnsNovPFIWKbRpIXjJSIucsT4gphH8D8wnMyc/rU8SOxiwvMtLpickymJCBjuam PHF6R0jHgJCf0XU+sa6Spvv8sE6Vv3OBJ1+g4WA4ya+xqL1SuBIIUBRGQWWfXeYCYJsB AaFrqxM6Ac0TS99TCUu0o+rfqapvMh+tseGt/ij5uEy5d0RmL0jEbuRBQ/QBknP82muN Ifig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc; bh=0Fwrp6nxrXLxGj0dPcOpp3eHE7TtqCEnW5Mdr8aBjEk=; b=jpiP8kSv9nCK/3e+AM239JMzjYSDCMCJTkHAbPNqhhuYSUpZBveiKGkXaWI5t9c1z2 O0vxS1yyEKzPJa5VZaLJRJTHfxfoMQkigZhdmfxKTD10oRSZJVMuox2pnZ2iEV7vl1RJ UM0zyDWmqw/Gop3gqBiQezVRpIYb5zpUEN3/szIp4AArfnkHiaiOaKLiCItMYK47b9Gu TCLsjCtwcnJddNMadjNc1dyox1wHQ9YCJmIo14jUabSNbBMmLAXkkNb/V4wx+lc58rJH CUaq/Tfz3Ot/d+762F31u7lQnuopGdpoJO+OQZ1Nik+bCIANz8crNF64Eecd5GUCu0Iy PgQA== X-Gm-Message-State: ACgBeo0mM9NAro0yxYoloIRAqlobE6TNeg1IH3okNjAl1UITsyG6uUyH BtaG+vLGCAAwodinlN1gqOW0UBKGATY= X-Google-Smtp-Source: AA6agR7iiU0wjTMtC/szBiTiDXRrc99jRVeAx2p7alVy36tqn9zZxvXDjZtgGPjQA8KbdKs2c59O5Q== X-Received: by 2002:a05:6402:3681:b0:446:ba68:573f with SMTP id ej1-20020a056402368100b00446ba68573fmr7600090edb.137.1661344874639; Wed, 24 Aug 2022 05:41:14 -0700 (PDT) Received: from localhost.localdomain ([2a02:ab88:7509:f780:ed82:a496:f55:e07b]) by smtp.gmail.com with ESMTPSA id f2-20020a17090631c200b006fee7b5dff2sm1114628ejf.143.2022.08.24.05.41.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 05:41:14 -0700 (PDT) From: Attila Lendvai Date: Wed, 24 Aug 2022 14:40:41 +0200 Message-Id: <20220824124042.10959-4-attila@lendvai.name> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220824124042.10959-1-attila@lendvai.name> References: <20220824124042.10959-1-attila@lendvai.name> 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: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1661347731; 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:dkim-signature; bh=EiCC7VcO9HgFRuQ1U61FGNn4W8fXoyvVApELr+3uLQI=; b=n0BMujfh7pL9W6ThClPgk6oJoSnvKYJv0AofpDKeqIqxWjE+n85V+1FfYf885ZHd0GqnOk Y1FCznGx2GqMZcoX1msfenVuj08RX8er2XGr/gYzq/VajXxbADW974frIH+4uwWWYLyFVb xDHJ08MbuAIPMAUPmWDgjTbrXvEfUzWZzSAtjzKseULDpFRTlqcLZl/RjeEJOONrvN46cJ joJtXpKneWOxoIBpHyKzl07o/y/dNiMXAaAWS/jC9pNdYMvnCT57Se++kHVLoRowB0UwfI RIt6jCYx6Wnr6f/Khycgy/p57r/DxEa8JE6bOrqAfRvEwlYl63Ser93cLccWbw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1661347731; a=rsa-sha256; cv=none; b=Hm6DqhgYTlkxZCz09fWJx9CsaUf4er/Wa8/ihp550WScoNfgwOm+T/OeKR4dlI3ay7CRNj lNCUswE6W+/glJKkOipVw+8gTX+sHr35BNtD4/dOnKFRzgHpHwmnwkqmFecnWvVGd27qY4 4JRxKzWU5+YvXXEVzpnawNkLqIhs6S4vg9W2uDOlg6Ct049ioADzc+t50W6XufbqOGjNvb nh2hz03sO7uPEo/cthlCB7pe7JCgKGk/hkAXzraSwAS1ZNJBuI+YtPBC10c6pMg5Y0Wci2 GFpk2VOJOeM66E9EFMSYZZF74keNRrBZQFkJ+HP8mCv8/7ojEKA9A6zZbj4R6g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=YSfoAIV2; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 4.19 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=YSfoAIV2; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 1858428A7A X-Spam-Score: 4.19 X-Migadu-Scanner: scn1.migadu.com X-TUID: y24K/dO3jwCJ * gnu/home/services/ssh.scm (serialize-address-family): Use the public API of the maybe infrastructure. * gnu/services/file-sharing.scm (serialize-maybe-string): Use maybe-value. (serialize-maybe-file-object): Use maybe-value-set?. * gnu/services/getmail.scm (getmail-retriever-configuration): Don't use internals in unset field declarations. (getmail-destination-configuration): Ditto. * gnu/services/messaging.scm (raw-content?): Use maybe-value-set?. (prosody-configuration): Use %unset-value. * gnu/services/telephony.scm (jami-shepherd-services): Use maybe-value-set?. (archive-name->username): Use maybe-value-set?. * tests/services/configuration.scm ("maybe type, no default"): Use %unset-value. --- gnu/home/services/ssh.scm | 12 +++++++----- gnu/services/file-sharing.scm | 11 ++++------- gnu/services/getmail.scm | 6 +++--- gnu/services/kerberos.scm | 1 + gnu/services/messaging.scm | 15 ++++++++++----- gnu/services/networking.scm | 2 +- gnu/services/telephony.scm | 6 +++--- tests/services/configuration.scm | 2 +- 8 files changed, 30 insertions(+), 25 deletions(-) diff --git a/gnu/home/services/ssh.scm b/gnu/home/services/ssh.scm index f0987aee23..d15f5ee912 100644 --- a/gnu/home/services/ssh.scm +++ b/gnu/home/services/ssh.scm @@ -69,17 +69,19 @@ (define (serialize-string field value) " " value "\n")) (define (address-family? obj) - (memv obj (list 'unset AF_INET AF_INET6))) + (memv obj (list AF_INET AF_INET6))) + +(define-maybe address-family) (define (serialize-address-family field family) - (if (eq? 'unset family) - "" + (if (maybe-value-set? family) (string-append " " (serialize-field-name field) " " (cond ((= family AF_INET) "inet") ((= family AF_INET6) "inet6") ;; The 'else' branch is unreachable. (else (raise (condition (&error))))) - "\n"))) + "\n") + "")) (define (natural-number? obj) (and (integer? obj) (exact? obj) (> obj 0))) @@ -115,7 +117,7 @@ (define-configuration openssh-host maybe-string "Host name---e.g., @code{\"foo.example.org\"} or @code{\"192.168.1.2\"}.") (address-family - address-family + maybe-address-family "Address family to use when connecting to this host: one of @code{AF_INET} (for IPv4 only), @code{AF_INET6} (for IPv6 only). Additionally, the field can be left unset to allow any address family.") diff --git a/gnu/services/file-sharing.scm b/gnu/services/file-sharing.scm index 5df8b0d597..75e99f20b7 100644 --- a/gnu/services/file-sharing.scm +++ b/gnu/services/file-sharing.scm @@ -114,10 +114,7 @@ (define-maybe string) ;; name-value pair for the JSON builder. (set! serialize-maybe-string (lambda (field-name val) - (serialize-string field-name - (if (eq? val 'unset) - "" - val)))) + (serialize-string field-name (maybe-value val "")))) (define (string-list? val) (and (list? val) @@ -180,9 +177,9 @@ (define (serialize-file-object field-name val) (define-maybe file-object) (set! serialize-maybe-file-object (lambda (field-name val) - (if (eq? val 'unset) - (serialize-string field-name "") - (serialize-file-object field-name val)))) + (if (maybe-value-set? val) + (serialize-file-object field-name val) + (serialize-string field-name "")))) (define (file-object-list? val) (and (list? val) diff --git a/gnu/services/getmail.scm b/gnu/services/getmail.scm index ce124f6b11..0a1c34cfd3 100644 --- a/gnu/services/getmail.scm +++ b/gnu/services/getmail.scm @@ -111,10 +111,10 @@ (define-configuration getmail-retriever-configuration "The type of mail retriever to use. Valid values include @samp{passwd} and @samp{static}.") (server - (string 'unset) + string "Name or IP address of the server to retrieve mail from.") (username - (string 'unset) + string "Username to login to the mail server with.") (port (non-negative-integer #f) @@ -143,7 +143,7 @@ (define (serialize-getmail-destination-configuration field-name val) (define-configuration getmail-destination-configuration (type - (string 'unset) + string "The type of mail destination. Valid values include @samp{Maildir}, @samp{Mboxrd} and @samp{MDA_external}.") (path diff --git a/gnu/services/kerberos.scm b/gnu/services/kerberos.scm index f845c1bd89..c3c7872734 100644 --- a/gnu/services/kerberos.scm +++ b/gnu/services/kerberos.scm @@ -39,6 +39,7 @@ (define-module (gnu services kerberos) +;; TODO Use %unset-value and the define-maybe infrastructure. (define unset-field (list 'unset-field)) (define (predicate/unset pred) diff --git a/gnu/services/messaging.scm b/gnu/services/messaging.scm index 00a1c80a14..59cb486778 100644 --- a/gnu/services/messaging.scm +++ b/gnu/services/messaging.scm @@ -90,6 +90,11 @@ (define (make-pred arg) ((new-def ...) (map (lambda (def target) (if (eq? 'common (syntax->datum target)) + ;; TODO Use the %unset-value variable, or + ;; even better just simplify this so that it + ;; doesn't interfere with + ;; define-configuration and define-maybe + ;; internals. #''unset def)) #'(def ...) #'(target ...))) ((new-doc ...) @@ -200,7 +205,7 @@ (define (serialize-file-object-list field-name val) (define-maybe file-object-list) (define (raw-content? val) - (not (eq? val 'unset))) + (maybe-value-set? val)) (define (serialize-raw-content field-name val) val) (define-maybe raw-content) @@ -474,12 +479,12 @@ (define-all-configurations prosody-configuration global) (http-max-content-size - (maybe-non-negative-integer 'unset) + (maybe-non-negative-integer %unset-value) "Maximum allowed size of the HTTP body (in bytes)." common) (http-external-url - (maybe-string 'unset) + (maybe-string %unset-value) "Some modules expose their own URL in various ways. This URL is built from the protocol, host and port used. If Prosody sits behind a proxy, the public URL will be @code{http-external-url} instead. See @@ -556,7 +561,7 @@ (define-all-configurations prosody-configuration int-component) (mod-muc - (maybe-mod-muc-configuration 'unset) + (maybe-mod-muc-configuration %unset-value) "Multi-user chat (MUC) is Prosody's module for allowing you to create hosted chatrooms/conferences for XMPP users. @@ -573,7 +578,7 @@ (define-all-configurations prosody-configuration ext-component) (raw-content - (maybe-raw-content 'unset) + (maybe-raw-content %unset-value) "Raw content that will be added to the configuration file." common))) diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 3c6395b6ca..9d85728371 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -772,7 +772,7 @@ (define-configuration/no-serialization opendht-configuration network. A specific port value can be provided by appending the @code{:PORT} suffix. By default, it uses the Jami bootstrap nodes, but any host can be specified here. It's also possible to disable bootstrapping by explicitly -setting this field to the @code{'unset} value.") +setting this field to @code{%unset-value}.") (port (maybe-number 4222) "The UDP port to bind to. When left unspecified, an available port is diff --git a/gnu/services/telephony.scm b/gnu/services/telephony.scm index 7152f3b38d..624b30116d 100644 --- a/gnu/services/telephony.scm +++ b/gnu/services/telephony.scm @@ -307,7 +307,7 @@ (define (jami-shepherd-services config) (dbus (jami-configuration-dbus config)) (dbus-daemon (file-append dbus "/bin/dbus-daemon")) (accounts (jami-configuration-accounts config)) - (declarative-mode? (not (eq? 'unset accounts)))) + (declarative-mode? (maybe-value-set? accounts))) (with-extensions (list guile-packrat ;used by guile-ac-d-bus guile-ac-d-bus @@ -649,7 +649,7 @@ (define (archive-name->username archive) account-details) (let ((username (archive-name->username archive))) - (when (not (eq? 'unset allowed-contacts)) + (when (maybe-value-set? allowed-contacts) ;; Reject calls from unknown contacts. (set-account-details '(("DHT.PublicInCalls" . "false")) username) @@ -659,7 +659,7 @@ (define (archive-name->username archive) ;; Add allowed ones. (for-each (cut add-contact <> username) allowed-contacts)) - (when (not (eq? 'unset moderators)) + (when (maybe-value-set? moderators) ;; Disable the 'AllModerators' property. (set-all-moderators #f username) ;; Remove all moderators. diff --git a/tests/services/configuration.scm b/tests/services/configuration.scm index 649dad26e8..8ed4ed4b66 100644 --- a/tests/services/configuration.scm +++ b/tests/services/configuration.scm @@ -169,7 +169,7 @@ (define-configuration config-with-maybe-string/no-serialization (not (defined? 'serialize-maybe-string))) (test-assert "maybe type, no default" - (eq? 'unset + (eq? %unset-value (config-with-maybe-string/no-serialization-name (config-with-maybe-string/no-serialization)))) -- 2.35.1