From unknown Sun Jun 22 00:35:23 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63320] [PATCH 0/2] Rewrite 'arguments' to gexps with 'guix style -S arguments' Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: julien@lepiller.eu, guix-patches@gnu.org Resent-Date: Fri, 05 May 2023 21:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 63320 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63320@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Julien Lepiller X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Julien Lepiller Received: via spool by submit@debbugs.gnu.org id=B.1683322250857 (code B ref -1); Fri, 05 May 2023 21:31:02 +0000 Received: (at submit) by debbugs.gnu.org; 5 May 2023 21:30:50 +0000 Received: from localhost ([127.0.0.1]:57667 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv30r-0000Dk-Ks for submit@debbugs.gnu.org; Fri, 05 May 2023 17:30:49 -0400 Received: from lists.gnu.org ([209.51.188.17]:50950) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv30m-0000DU-FS for submit@debbugs.gnu.org; Fri, 05 May 2023 17:30:47 -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 1pv30k-0000qH-BA for guix-patches@gnu.org; Fri, 05 May 2023 17:30:42 -0400 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 1pv30i-0006At-I5; Fri, 05 May 2023 17:30:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=tWcNMre0NgGbwW23xkvMp3uQRUcrb4qmZ0V7ZWqgyUI=; b=LgqjxXyEljEAEf SxfcjfZ9lRWLV21kIIBVo0kQYfQB+RpV1f5HIlb2tw/YMW8XPI1j29rI/VQOoORmxJESukoOcrlLa gqDE848hU6PyCsnna6pJ9pLe3zo9bXv4wShQxxojgIlxnbLV658ATzdjlUtyU3Dneg8bbqvtukrT0 Tzg2ZbQYC/ASqySOLfeD4ghmYAe6jV0wL7SE0dx1AUFzOLyAH+TZxx78EUXmtBpa6qG7z8VaRRGMc NHpqzWn4HcJzKKMmi9UCN2rPNGhT4QkVFIxAq7JbDSjgmpq1rwe2xVloHR36/qgoHDOOkAI+k4agf lCmkuSFKMHik/PPJGbww==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pv30i-0003xr-3g; Fri, 05 May 2023 17:30:40 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Fri, 5 May 2023 23:30:19 +0200 Message-Id: X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hello Guix! When preparing , I didn’t consider converting ‘arguments’ from sexps to gexps a priority. In practice, we’ve been doing that manually ever since but there’s a sort of a “contamination” aspect: due to inheritance, we often have to be careful enough to convert multiple packages at once or to not change anything, or we end up with gexp records inside sexps¹. Automation appears to be overdue. The attached patches add ‘guix style -S arguments’, which rewrites ‘arguments’ from sexps to gexps. The change doesn’t involve any rebuild, so we could even run it en masse on the whole repo and be done with it. Some caveats: • The reader in (guix read-print) doesn’t support sexp comments (#;), which are used in a couple of packages. Thus, ./pre-inst-env guix style -S arguments which traverses all the packages eventually chokes on it. • The pretty printer does not insert a newline after #:phases, which makes the space for (modify-phases …) expressions sometimes too narrow. (This is not new; try ‘./pre-inst-env guix style PACKAGE’.) • More generally, the pretty printer’s output still has occasional glitches, sufficiently that running ‘guix style -S arguments’ on the whole repo may not be a good idea at the moment. • Some modules lack #:use-module (guix gexp), but this has to be added manually. • We might want an optional conservative policy to leave arguments that would not use gexps unchanged. For instance, we could leave (arguments '(#:tests? #f)) unchanged instead of rewriting it to (arguments (list #:tests? #f)). Thoughts? Ludo’. ¹ This is what prompted Chris to improve error detection: . Ludovic Courtès (2): style: Add 'arguments' styling rule. DRAFT news: Add entry to 'guix style -S arguments'. doc/guix.texi | 51 ++++++++++++ etc/news.scm | 16 ++++ guix/scripts/style.scm | 173 ++++++++++++++++++++++++++++++++++++++++- tests/style.scm | 136 ++++++++++++++++++++++++++++++++ 4 files changed, 375 insertions(+), 1 deletion(-) base-commit: 3c91f4ca490a7ac56dc0aebbca9c4bf4df201877 -- 2.39.2 From unknown Sun Jun 22 00:35:23 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63320] [PATCH 2/2] DRAFT news: Add entry to 'guix style -S arguments'. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: julien@lepiller.eu, guix-patches@gnu.org Resent-Date: Fri, 05 May 2023 21:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63320 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63320@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Julien Lepiller X-Debbugs-Original-Xcc: Julien Lepiller Received: via spool by 63320-submit@debbugs.gnu.org id=B63320.16833228572028 (code B ref 63320); Fri, 05 May 2023 21:41:02 +0000 Received: (at 63320) by debbugs.gnu.org; 5 May 2023 21:40:57 +0000 Received: from localhost ([127.0.0.1]:57676 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv3Ae-0000Wd-QX for submit@debbugs.gnu.org; Fri, 05 May 2023 17:40:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42060) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv3Ad-0000WH-96 for 63320@debbugs.gnu.org; Fri, 05 May 2023 17:40:55 -0400 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 1pv3AX-0001Gg-Jz; Fri, 05 May 2023 17:40:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=/FYLqIwBrQzoZd57i56nUsjfd10jOyF6CsQE6i8Q1m8=; b=OOW53PMrMKKcH7/bphm2 8qftzct1gCSnnxsD1179OMZxqvUxcwmeCCZM8nuuhMYeHUNvt8O5drfaBOGe26d41qAe9sdq9GbOv hzk5m33b4fhJK3NrkPdgl66CkljE40xEPSuCc3doodH/5QCmuTSSuUVex5M0Fe6XR6tBrW/WLFfsL OWD9TyNrnSLvDzJ+wT2yuCvAGGQfpsMOexm60ypgDK/34gKbURc4o1PLsbd/FUhIoMZXTT1v8n7aT fx13YTFSlLCdWJM6Xa5XwuE4p28LFeCcTBnH/W0TQyw9ZCRwtpwuWgbuGwE9oan8wJpeeQFUW2E65 88V6eDzGOJHEtA==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pv3AX-0006Bu-5o; Fri, 05 May 2023 17:40:49 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Fri, 5 May 2023 23:40:05 +0200 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) DRAFT: Missing commit ID. * etc/news.scm: Add entry. --- etc/news.scm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/etc/news.scm b/etc/news.scm index 22f04e4dae..41a03405a7 100644 --- a/etc/news.scm +++ b/etc/news.scm @@ -26,6 +26,22 @@ (channel-news (version 0) + (entry (commit "FIXME") + (title + (en "New @code{arguments} rule for @command{guix style}")) + (body + (en "The @command{guix style} command has a new @dfn{styling rule} +for package definitions. Package writers may now run the following command: + +@example +guix style -L /path/to/channel -S arguments @var{package} +@end example + +This command rewrites the @code{arguments} field of @var{package} so that it +uses G-expressions instead of classical quasiquotation. + +Run @command{info \"(guix) Invoking guix style\"} for more info."))) + (entry (commit "ae11fcb84ac478dfa56d322ef08890645183a087") (title (en "New @option{--with-configure-flag} transformation option") -- 2.39.2 From unknown Sun Jun 22 00:35:23 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63320] [PATCH 1/2] style: Add 'arguments' styling rule. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: me@tobias.gr, guix-patches@gnu.org Resent-Date: Fri, 05 May 2023 21:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63320 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63320@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Tobias Geerinckx-Rice Received: via spool by 63320-submit@debbugs.gnu.org id=B63320.16833228582035 (code B ref 63320); Fri, 05 May 2023 21:41:02 +0000 Received: (at 63320) by debbugs.gnu.org; 5 May 2023 21:40:58 +0000 Received: from localhost ([127.0.0.1]:57678 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv3Af-0000Wf-4J for submit@debbugs.gnu.org; Fri, 05 May 2023 17:40:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42068) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv3Ad-0000WI-Ab for 63320@debbugs.gnu.org; Fri, 05 May 2023 17:40:56 -0400 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 1pv3AW-0001GK-PT; Fri, 05 May 2023 17:40:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=uQyS+fgbCAdQs2drO0kv0W2Jnj0sDs1tgCUGVqpNSEA=; b=CzG8cjZQwLQS+XECXFmA vmgVrenFk6GDpv4kxND7dnr7OXA3bJrReOdUOJHe5tNUs8WV2f5Q0JueZZOdo7X0vgE8R9O9u9qSH UT2FHgWlZk9RhO1fs5lEYsibxHXCsbX5iCiBqAeowzFPv0F8WfO+A11XGuVcJD9CdXc55uQVjPgwR jQLeuaVoN0//gYWSNZ+Vsb2e01tJL2waDlh30MRfElT5IZzEb7G97QPRH4CRjhJ/yB28HDMyTkpWd kmtxzNQa8dUZfRJA7STO6RaIkd5S6M6GUYqdaBBkfvk9kaWyFjepKc70z6TNnx/tbXUmQ0+rRR7D2 1P7+h/ywM/Bf5A==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pv39z-0006Bu-P2; Fri, 05 May 2023 17:40:39 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Fri, 5 May 2023 23:40:04 +0200 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * guix/scripts/style.scm (unquote->ungexp, gexpify-argument-value) (quote-argument-value, gexpify-argument-tail) (gexpify-package-arguments): New procedures. (%gexp-keywords): New variable. (%options): Add "arguments" case for 'styling-procedure. (show-stylings): Update. * tests/style.scm ("gexpify arguments, already gexpified") ("gexpify arguments, non-gexp arguments, margin comment") ("gexpify arguments, phases and flags") ("gexpify arguments, append arguments") ("gexpify arguments, substitute-keyword-arguments") ("gexpify arguments, append substitute-keyword-arguments"): New tests. * doc/guix.texi (package Reference): For 'arguments', add compatibility note and link to 'guix style'. (Invoking guix style): Document the 'arguments' styling rule. --- doc/guix.texi | 51 ++++++++++++ guix/scripts/style.scm | 173 ++++++++++++++++++++++++++++++++++++++++- tests/style.scm | 136 ++++++++++++++++++++++++++++++++ 3 files changed, 359 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index 55221a10c3..12d7e02bca 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -7743,6 +7743,24 @@ package Reference @code{#:phases}. The @code{#:phases} keyword in particular lets you modify the set of build phases for your package (@pxref{Build Phases}). +@quotation Compatibility Note +Until version 1.3.0, the @code{arguments} field would typically use +@code{quote} (@code{'}) or @code{quasiquote} (@code{`}) and no +G-expressions, like so: + +@lisp +(package + ;; several fields omitted + (arguments ;old-style quoted arguments + '(#:tests? #f + #:configure-flags '("--enable-frobbing")))) +@end lisp + +To convert from that style to the one shown above, you can run +@code{guix style -S arguments @var{package}} (@pxref{Invoking guix +style}). +@end quotation + @item @code{inputs} (default: @code{'()}) @itemx @code{native-inputs} (default: @code{'()}) @itemx @code{propagated-inputs} (default: @code{'()}) @@ -14657,6 +14675,39 @@ Invoking guix style out if it cannot make sense of the code that appears in an inputs field. The @option{--input-simplification} option described below provides fine-grain control over when inputs should be simplified. + +@item arguments +Rewrite package arguments to use G-expressions (@pxref{G-Expressions}). +For example, consider this package definition: + +@lisp +(define-public my-package + (package + ;; @dots{} + (arguments ;old-style quoted arguments + '(#:make-flags '("V=1") + #:phases (modify-phases %standard-phases + (delete 'build)))))) +@end lisp + +@noindent +Running @command{guix style -S arguments} on this package would rewrite +its @code{arguments} field like to: + +@lisp +(define-public my-package + (package + ;; @dots{} + (arguments + (list #:make-flags #~'("V=1") + #:phases #~(modify-phases %standard-phases + (delete 'build)))))) +@end lisp + +Note that changes made by the @code{arguments} rule do not entail a +rebuild of the affected packages. Furthermore, if a package definition +happens to be using G-expressions already, @command{guix style} leaves +it unchanged. @end table @item --list-stylings diff --git a/guix/scripts/style.scm b/guix/scripts/style.scm index 00c7d3f90c..1d02742524 100644 --- a/guix/scripts/style.scm +++ b/guix/scripts/style.scm @@ -41,6 +41,7 @@ (define-module (guix scripts style) #:use-module (ice-9 match) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) + #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) #:use-module (srfi srfi-37) #:export (guix-style)) @@ -302,6 +303,174 @@ (define* (simplify-package-inputs package (list package-inputs package-native-inputs package-propagated-inputs))) + +;;; +;;; Gexpifying package arguments. +;;; + +(define (unquote->ungexp value) + "Replace 'unquote' and 'unquote-splicing' in VALUE with their gexp +counterpart." + ;; Replace 'unquote only on the first quasiquotation level. + (let loop ((value value) + (quotation 1)) + (match value + (('unquote x) + (if (= quotation 1) + `(ungexp ,x) + value)) + (('unquote-splicing x) + (if (= quotation 1) + `(ungexp-splicing x) + value)) + (('quasiquote x) + (list 'quasiquote (loop x (+ quotation 1)))) + (('quote x) + (list 'quote (loop x (+ quotation 1)))) + ((lst ...) + (map (cut loop <> quotation) lst)) + (x x)))) + +(define (gexpify-argument-value value quotation) + "Turn VALUE, an sexp, into its gexp equivalent. QUOTATION is a symbol that +indicates in what quotation context VALUE is to be interpreted: 'quasiquote, +'quote, or 'none." + (match quotation + ('none + (match value + (('quasiquote value) + (gexpify-argument-value value 'quasiquote)) + (('quote value) + (gexpify-argument-value value 'quote)) + (value value))) + ('quote + `(gexp ,value)) + ('quasiquote + `(gexp ,(unquote->ungexp value))))) + +(define (quote-argument-value value quotation) + "Quote VALUE, an sexp. QUOTATION is a symbol that indicates in what +quotation context VALUE is to be interpreted: 'quasiquote, 'quote, or 'none." + (define (self-quoting? x) + (or (boolean? x) (number? x) (string? x) (char? x) + (keyword? x))) + + (match quotation + ('none + (match value + (('quasiquote value) + (quote-argument-value value 'quasiquote)) + (('quote value) + (quote-argument-value value 'quote)) + (value value))) + ('quote + (if (self-quoting? value) + value + (list 'quote value))) + ('quasiquote + (match value + (('unquote x) x) + ((? self-quoting? x) x) + (_ (list 'quasiquote value)))))) + +(define %gexp-keywords + ;; Package argument keywords that must be followed by a gexp. + '(#:phases #:configure-flags #:make-flags #:strip-flags)) + +(define (gexpify-argument-tail sexp) + "Gexpify SEXP, an unquoted argument tail." + (match sexp + (('substitute-keyword-arguments lst clauses ...) + `(substitute-keyword-arguments ,lst + ,@(map (match-lambda + ((((? keyword? keyword) identifier) body) + `((,keyword ,identifier) + ,(if (memq keyword %gexp-keywords) + (gexpify-argument-value body 'none) + (quote-argument-value body 'none)))) + ((((? keyword? keyword) identifier default) body) + `((,keyword ,identifier + ,(if (memq keyword %gexp-keywords) + (gexpify-argument-value default 'none) + (quote-argument-value default 'none))) + ,(if (memq keyword %gexp-keywords) + (gexpify-argument-value body 'none) + (quote-argument-value body 'none)))) + (clause clause)) + clauses))) + (_ sexp))) + +(define* (gexpify-package-arguments package + #:key + (policy 'none) + (edit-expression edit-expression)) + "Rewrite the 'arguments' field of PACKAGE to use gexps where applicable." + (define (gexpify location str) + (match (call-with-input-string str read-with-comments) + ((rest ...) + (let ((blanks (take-while blank? rest)) + (value (drop-while blank? rest))) + (define-values (quotation arguments tail) + (match value + (('quote (arguments ...)) (values 'quote arguments '())) + (('quasiquote (arguments ... ('unquote-splicing tail))) + (values 'quasiquote arguments tail)) + (('quasiquote (arguments ...)) (values 'quasiquote arguments '())) + (('list arguments ...) (values 'none arguments '())) + (arguments (values 'none '() arguments)))) + + (define (append-tail sexp) + (if (null? tail) + sexp + (let ((tail (gexpify-argument-tail tail))) + (if (null? arguments) + tail + `(append ,sexp ,tail))))) + + (let/ec return + (object->string* + (append-tail + `(list ,@(let loop ((arguments arguments) + (result '())) + (match arguments + (() (reverse result)) + (((? keyword? keyword) value rest ...) + (when (eq? quotation 'none) + (match value + (('gexp _) ;already gexpified + (return str)) + (_ #f))) + + (loop rest + (cons* (if (memq keyword %gexp-keywords) + (gexpify-argument-value value + quotation) + (quote-argument-value value quotation)) + keyword result))) + (((? blank? blank) rest ...) + (loop rest (cons blank result))) + (_ + ;; Something like: ,@(package-arguments xyz). + (warning location + (G_ "unsupported argument style; \ +bailing out~%")) + (return str)))))) + (location-column location))))) + (_ + (warning location + (G_ "unsupported argument field; bailing out~%")) + str))) + + (unless (null? (package-arguments package)) + (match (package-field-location package 'arguments) + (#f + #f) + (location + (edit-expression + (location->source-properties (absolute-location location)) + (lambda (str) + (gexpify location str))))))) + ;;; ;;; Formatting package definitions. @@ -379,6 +548,7 @@ (define %options (alist-cons 'styling-procedure (match arg ("inputs" simplify-package-inputs) + ("arguments" gexpify-package-arguments) ("format" format-package-definition) (_ (leave (G_ "~a: unknown styling~%") arg))) @@ -407,7 +577,8 @@ (define %options (define (show-stylings) (display (G_ "Available styling rules:\n")) (display (G_ "- format: Format the given package definition(s)\n")) - (display (G_ "- inputs: Rewrite package inputs to the “new style”\n"))) + (display (G_ "- inputs: Rewrite package inputs to the “new style”\n")) + (display (G_ "- arguments: Rewrite package arguments to G-expressions\n"))) (define (show-help) (display (G_ "Usage: guix style [OPTION]... [PACKAGE]... diff --git a/tests/style.scm b/tests/style.scm index f141a57d7f..5e38549606 100644 --- a/tests/style.scm +++ b/tests/style.scm @@ -386,6 +386,142 @@ (define* (read-package-field package field #:optional (count 1)) (list (package-inputs (@ (my-packages) my-coreutils)) (read-package-field (@ (my-packages) my-coreutils) 'inputs 4))))) +(test-assert "gexpify arguments, already gexpified" + (call-with-test-package '((arguments + (list #:configure-flags #~'("--help")))) + (lambda (directory) + (define file + (string-append directory "/my-packages.scm")) + (define (fingerprint file) + (let ((stat (stat file))) + (list (stat:mtime stat) (stat:size stat)))) + (define before + (fingerprint file)) + + (system* "guix" "style" "-L" directory "my-coreutils" + "-S" "arguments") + + (equal? (fingerprint file) before)))) + +(test-equal "gexpify arguments, non-gexp arguments, margin comment" + (list (list #:tests? #f #:test-target "check") + "\ + (arguments (list #:tests? #f ;no tests + #:test-target \"check\"))\n") + (call-with-test-package '((arguments + '(#:tests? #f + #:test-target "check"))) + (lambda (directory) + (define file + (string-append directory "/my-packages.scm")) + + (substitute* file + (("#:tests\\? #f" all) + (string-append all " ;no tests\n"))) + + (system* "guix" "style" "-L" directory "my-coreutils" + "-S" "arguments") + + (load file) + (list (package-arguments (@ (my-packages) my-coreutils)) + (read-package-field (@ (my-packages) my-coreutils) 'arguments 2))))) + +(test-equal "gexpify arguments, phases and flags" + "\ + (list #:tests? #f + #:configure-flags #~'(\"--fast\") + #:make-flags #~(list (string-append \"CC=\" + #$(cc-for-target))) + #:phases #~(modify-phases %standard-phases + ;; Line comment. + whatever)))\n" + (call-with-test-package '((arguments + `(#:tests? #f + #:configure-flags '("--fast") + #:make-flags + (list (string-append "CC=" ,(cc-for-target))) + #:phases (modify-phases %standard-phases + whatever)))) + (lambda (directory) + (define file + (string-append directory "/my-packages.scm")) + + (substitute* file + (("whatever") + "\n;; Line comment. + whatever")) + (system* "guix" "style" "-L" directory "my-coreutils" + "-S" "arguments") + + (load file) + (read-package-field (@ (my-packages) my-coreutils) 'arguments 7)))) + +(test-equal "gexpify arguments, append arguments" + "\ + (append (list #:tests? #f + #:configure-flags #~'(\"--fast\")) + (package-arguments coreutils)))\n" + (call-with-test-package '((arguments + `(#:tests? #f + #:configure-flags '("--fast") + ,@(package-arguments coreutils)))) + (lambda (directory) + (define file + (string-append directory "/my-packages.scm")) + + (system* "guix" "style" "-L" directory "my-coreutils" + "-S" "arguments") + + (load file) + (read-package-field (@ (my-packages) my-coreutils) 'arguments 3)))) + +(test-equal "gexpify arguments, substitute-keyword-arguments" + "\ + (substitute-keyword-arguments (package-arguments coreutils) + ((#:tests? _ #f) + #t) + ((#:make-flags flags + #~'()) + #~(cons \"-DXYZ=yes\" + #$flags))))\n" + (call-with-test-package '((arguments + (substitute-keyword-arguments + (package-arguments coreutils) + ((#:tests? _ #f) #t) + ((#:make-flags flags ''()) + `(cons "-DXYZ=yes" ,flags))))) + (lambda (directory) + (define file + (string-append directory "/my-packages.scm")) + + (system* "guix" "style" "-L" directory "my-coreutils" + "-S" "arguments") + + (load file) + (read-package-field (@ (my-packages) my-coreutils) 'arguments 7)))) + +(test-equal "gexpify arguments, append substitute-keyword-arguments" + "\ + (append (list #:tests? #f) + (substitute-keyword-arguments (package-arguments coreutils) + ((#:make-flags flags) + #~(append `(\"-n\" ,%output) + #$flags)))))\n" + (call-with-test-package '((arguments + `(#:tests? #f + ,@(substitute-keyword-arguments + (package-arguments coreutils) + ((#:make-flags flags) + `(append `("-n" ,%output) ,flags)))))) + (lambda (directory) + (define file + (string-append directory "/my-packages.scm")) + + (system* "guix" "style" "-L" directory "my-coreutils" + "-S" "arguments") + + (load file) + (read-package-field (@ (my-packages) my-coreutils) 'arguments 5)))) (test-end) -- 2.39.2 From unknown Sun Jun 22 00:35:23 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63320] [PATCH 2/2] DRAFT news: Add entry to 'guix style -S arguments'. Resent-From: "pelzflorian (Florian Pelz)" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 06 May 2023 10:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63320 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 63320@debbugs.gnu.org, Julien Lepiller Received: via spool by 63320-submit@debbugs.gnu.org id=B63320.16833698384144 (code B ref 63320); Sat, 06 May 2023 10:44:02 +0000 Received: (at 63320) by debbugs.gnu.org; 6 May 2023 10:43:58 +0000 Received: from localhost ([127.0.0.1]:59511 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvFOP-00014m-SM for submit@debbugs.gnu.org; Sat, 06 May 2023 06:43:58 -0400 Received: from relay.yourmailgateway.de ([188.68.63.170]:51139) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvFON-00014d-NO for 63320@debbugs.gnu.org; Sat, 06 May 2023 06:43:56 -0400 Received: from mors-relay8203.netcup.net (localhost [127.0.0.1]) by mors-relay8203.netcup.net (Postfix) with ESMTPS id 4QD40p0GQDz8YcB; Sat, 6 May 2023 10:43:54 +0000 (UTC) Authentication-Results: mors-relay8203.netcup.net; dkim=permerror (bad message/signature format) Received: from policy01-mors.netcup.net (unknown [46.38.225.35]) by mors-relay8203.netcup.net (Postfix) with ESMTPS id 4QD40n6grSz8YZs; Sat, 6 May 2023 10:43:53 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at policy01-mors.netcup.net X-Spam-Flag: NO X-Spam-Score: -2.9 X-Spam-Level: X-Spam-Status: No, score=-2.9 required=6.31 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9] autolearn=ham autolearn_force=no Received: from mxe217.netcup.net (unknown [10.243.12.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by policy01-mors.netcup.net (Postfix) with ESMTPS id 4QD40n346xz8t47; Sat, 6 May 2023 12:43:53 +0200 (CEST) Received: from florianrock64 (ip92344de0.dynamic.kabel-deutschland.de [146.52.77.224]) by mxe217.netcup.net (Postfix) with ESMTPSA id C4E7880471; Sat, 6 May 2023 12:43:46 +0200 (CEST) From: "pelzflorian (Florian Pelz)" References: Date: Sat, 06 May 2023 12:43:45 +0200 In-Reply-To: ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Fri, 5 May 2023 23:40:05 +0200") Message-ID: <87ild57na6.fsf@pelzflorian.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: C4E7880471 X-Spamd-Result: default: False [-5.60 / 15.00]; BAYES_HAM(-5.50)[99.99%]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:3209, ipnet:146.52.0.0/16, country:DE]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[] X-Rspamd-Server: rspamd-worker-8404 X-NC-CID: ZYMnQ+IJ40mgSa804obGtv5koJWOlOFAbKodpKTqnWpdQuDtgwQ9AlV9 X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Ludo. Would you add this German translation: (title (en =E2=80=A6) (de "Neue Stilregel @code{arguments} f=C3=BCr @command{guix style}")) (body (en =E2=80=A6) (de "Der Befehl @command{guix style} verf=C3=BCgt =C3=BCber eine neue @dfn= {Stilregel} f=C3=BCr Paketdefinitionen. Paketautoren k=C3=B6nnen jetzt folgenden Befeh= l benutzen: @example guix style -L /pfad/zum/kanal -S arguments @var{Paket} @end example Dadurch wird das Feld @code{arguments} in @var{Paket} so umgeschrieben, dass G-Ausdr=C3=BCcke (gexps) anstelle von klassischer Quasiquotierung verwendet werden. F=C3=BChren Sie @command{info \"(guix.de) Aufruf von guix style\"} aus, um mehr Informationen zu erhalten."))) Regards, Florian From unknown Sun Jun 22 00:35:23 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Subject: bug#63320: closed (Re: bug#63320: [PATCH 0/2] Rewrite 'arguments' to gexps with 'guix style -S arguments') Message-ID: References: <87y1ll1peq.fsf@gnu.org> X-Gnu-PR-Message: they-closed 63320 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 63320@debbugs.gnu.org Date: Thu, 18 May 2023 18:11:01 +0000 Content-Type: multipart/mixed; boundary="----------=_1684433461-8821-1" This is a multi-part message in MIME format... ------------=_1684433461-8821-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #63320: [PATCH 0/2] Rewrite 'arguments' to gexps with 'guix style -S argume= nts' which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 63320@debbugs.gnu.org. --=20 63320: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D63320 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1684433461-8821-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 63320-done) by debbugs.gnu.org; 18 May 2023 18:10:54 +0000 Received: from localhost ([127.0.0.1]:54482 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzi5W-0002Hw-Ba for submit@debbugs.gnu.org; Thu, 18 May 2023 14:10:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60128) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzi5R-0002Hg-Ir for 63320-done@debbugs.gnu.org; Thu, 18 May 2023 14:10:53 -0400 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 1pzi5J-0007e9-Bq; Thu, 18 May 2023 14:10:41 -0400 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=OvpVSs5vU4S/kKiosagu1JONqEPs1G2BlXMxsLOY6CY=; b=k0TPP4R1eS601+64x+ti O4BglSIqrcNolDTfMbD8k/3wF9dcm0m0kpc9dg8QJ3URVxOIjp5je5vpOKm4o6AWMSXOMEmnhFswW 3qjhfi2b5Qxhe4/OuEtFsfuCl2DrDQ3xyZo8Qupb2y0bUMB2W6VwVY1/l/zF20gbToYCCys4PPicM EjU/pGt19ZPZgcsJMfQDCEljMawz6CA1WSCASu/W8AzHAl5zpKrRKMkaRiP5noE1x38q7o0y0i0y5 hBlbXNLrwuCiRe3lpQm2kuPms40aILsxQH/vMv0LKx9tk2RBnhodvxT3Q1ssmLDd1gqB4U/4XLJtB qfSpfRl6pAg8EA==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzi5I-0008Q1-VV; Thu, 18 May 2023 14:10:41 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: 63320-done@debbugs.gnu.org Subject: Re: bug#63320: [PATCH 0/2] Rewrite 'arguments' to gexps with 'guix style -S arguments' References: Date: Thu, 18 May 2023 20:10:37 +0200 In-Reply-To: ("Ludovic =?utf-8?Q?Court?= =?utf-8?Q?=C3=A8s=22's?= message of "Fri, 5 May 2023 23:30:19 +0200") Message-ID: <87y1ll1peq.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63320-done Cc: Julien Lepiller , "pelzflorian \(Florian Pelz\)" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, Ludovic Court=C3=A8s skribis: > When preparing , I did= n=E2=80=99t > consider converting =E2=80=98arguments=E2=80=99 from sexps to gexps a pri= ority. In practice, > we=E2=80=99ve been doing that manually ever since but there=E2=80=99s a s= ort of a =E2=80=9Ccontamination=E2=80=9D > aspect: due to inheritance, we often have to be careful enough to convert > multiple packages at once or to not change anything, or we end up with ge= xp > records inside sexps=C2=B9. Automation appears to be overdue. > > The attached patches add =E2=80=98guix style -S arguments=E2=80=99, which= rewrites =E2=80=98arguments=E2=80=99 > from sexps to gexps. The change doesn=E2=80=99t involve any rebuild, so = we could even > run it en masse on the whole repo and be done with it. Pushed as 2344ccee2f28f790fa0b69ecb1916c162c1f8c50, with Florian=E2=80=99s news entry translation (I just realized I forgot to add you as co-author, my apologies!). I guess we should address the shortcomings I mentioned before we can run it on the whole repo. Thanks, Ludo=E2=80=99. ------------=_1684433461-8821-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 5 May 2023 21:30:50 +0000 Received: from localhost ([127.0.0.1]:57667 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv30r-0000Dk-Ks for submit@debbugs.gnu.org; Fri, 05 May 2023 17:30:49 -0400 Received: from lists.gnu.org ([209.51.188.17]:50950) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pv30m-0000DU-FS for submit@debbugs.gnu.org; Fri, 05 May 2023 17:30:47 -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 1pv30k-0000qH-BA for guix-patches@gnu.org; Fri, 05 May 2023 17:30:42 -0400 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 1pv30i-0006At-I5; Fri, 05 May 2023 17:30:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=tWcNMre0NgGbwW23xkvMp3uQRUcrb4qmZ0V7ZWqgyUI=; b=LgqjxXyEljEAEf SxfcjfZ9lRWLV21kIIBVo0kQYfQB+RpV1f5HIlb2tw/YMW8XPI1j29rI/VQOoORmxJESukoOcrlLa gqDE848hU6PyCsnna6pJ9pLe3zo9bXv4wShQxxojgIlxnbLV658ATzdjlUtyU3Dneg8bbqvtukrT0 Tzg2ZbQYC/ASqySOLfeD4ghmYAe6jV0wL7SE0dx1AUFzOLyAH+TZxx78EUXmtBpa6qG7z8VaRRGMc NHpqzWn4HcJzKKMmi9UCN2rPNGhT4QkVFIxAq7JbDSjgmpq1rwe2xVloHR36/qgoHDOOkAI+k4agf lCmkuSFKMHik/PPJGbww==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pv30i-0003xr-3g; Fri, 05 May 2023 17:30:40 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: guix-patches@gnu.org Subject: [PATCH 0/2] Rewrite 'arguments' to gexps with 'guix style -S arguments' Date: Fri, 5 May 2023 23:30:19 +0200 Message-Id: X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Debbugs-Cc: Florian Pelz X-Debbugs-Cc: Julien Lepiller Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hello Guix! When preparing , I didn’t consider converting ‘arguments’ from sexps to gexps a priority. In practice, we’ve been doing that manually ever since but there’s a sort of a “contamination” aspect: due to inheritance, we often have to be careful enough to convert multiple packages at once or to not change anything, or we end up with gexp records inside sexps¹. Automation appears to be overdue. The attached patches add ‘guix style -S arguments’, which rewrites ‘arguments’ from sexps to gexps. The change doesn’t involve any rebuild, so we could even run it en masse on the whole repo and be done with it. Some caveats: • The reader in (guix read-print) doesn’t support sexp comments (#;), which are used in a couple of packages. Thus, ./pre-inst-env guix style -S arguments which traverses all the packages eventually chokes on it. • The pretty printer does not insert a newline after #:phases, which makes the space for (modify-phases …) expressions sometimes too narrow. (This is not new; try ‘./pre-inst-env guix style PACKAGE’.) • More generally, the pretty printer’s output still has occasional glitches, sufficiently that running ‘guix style -S arguments’ on the whole repo may not be a good idea at the moment. • Some modules lack #:use-module (guix gexp), but this has to be added manually. • We might want an optional conservative policy to leave arguments that would not use gexps unchanged. For instance, we could leave (arguments '(#:tests? #f)) unchanged instead of rewriting it to (arguments (list #:tests? #f)). Thoughts? Ludo’. ¹ This is what prompted Chris to improve error detection: . Ludovic Courtès (2): style: Add 'arguments' styling rule. DRAFT news: Add entry to 'guix style -S arguments'. doc/guix.texi | 51 ++++++++++++ etc/news.scm | 16 ++++ guix/scripts/style.scm | 173 ++++++++++++++++++++++++++++++++++++++++- tests/style.scm | 136 ++++++++++++++++++++++++++++++++ 4 files changed, 375 insertions(+), 1 deletion(-) base-commit: 3c91f4ca490a7ac56dc0aebbca9c4bf4df201877 -- 2.39.2 ------------=_1684433461-8821-1--