[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#70923] [PATCH v4 02/11] import: utils: Emit new-style package input
From: |
Herman Rimm |
Subject: |
[bug#70923] [PATCH v4 02/11] import: utils: Emit new-style package inputs. |
Date: |
Mon, 9 Dec 2024 20:58:06 +0100 |
From: Sarah Morgensen <iskarian@mgsn.dev>
* guix/import/utils.scm (package-names->package-inputs)[make-input]:
Return new-style package inputs.
(maybe-list-field): Add procedure, which wraps BODY in 'list' instead of
'quasiquote'.
(maybe-packages-field): Add procedure.
(maybe-inputs): Use maybe-packages-field.
(maybe-native-inputs): Use maybe-packages-field.
(maybe-propagated-inputs): Use maybe-packages-field.
Change-Id: I66588f4c822d507ddbaf465a268bfb71af8a7ecd
---
guix/import/utils.scm | 52 +++++++++++++++++++++++++------------------
1 file changed, 30 insertions(+), 22 deletions(-)
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index ccf18a7bf9..4eab790645 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -13,6 +13,7 @@
;;; Copyright © 2022 Alice Brenon <alice.brenon@ens-lyon.fr>
;;; Copyright © 2022 Kyle Meyer <kyle@kyleam.com>
;;; Copyright © 2022 Philip McGrath <philip@philipmcgrath.com>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -65,6 +66,8 @@ (define-module (guix import utils)
guix-hash-url
package-names->package-inputs
+ maybe-list-field
+ maybe-packages-field
maybe-inputs
maybe-native-inputs
maybe-propagated-inputs
@@ -425,39 +428,44 @@ (define* (package-names->package-inputs names #:optional
(output #f))
optional OUTPUT, tries to generate a quoted list of inputs, as suitable to
use in an 'inputs' field of a package definition."
(define (make-input input version)
- (let ((name (if version (string-append input "-" version) input)))
+ (let ((symbol (string->symbol
+ (if version
+ (string-append input "-" version)
+ input))))
(if output
- (list (string->symbol name) output)
- (string->symbol name))))
+ (list symbol output)
+ symbol)))
(map (match-lambda
((input version) (make-input input version))
(input (make-input input #f)))
names))
-(define* (maybe-inputs package-names #:optional (output #f)
- #:key (type #f))
- "Given a list of PACKAGE-NAMES, tries to generate the 'inputs' field of a
-package definition. TYPE can be used to specify the type of the inputs;
-either the 'native or 'propagated symbols are accepted. Left unspecified, the
-snippet generated is for regular inputs."
- (let ((field-name (match type
- ('native 'native-inputs)
- ('propagated 'propagated-inputs)
- (_ 'inputs))))
- (match (package-names->package-inputs package-names output)
- (()
- '())
- ((package-inputs ...)
- `((,field-name (list ,@package-inputs)))))))
+(define* (maybe-list-field type body)
+ "Generates the TYPE field of a package definition if its value, BODY,
+is a non-empty list."
+ (match body
+ (() '())
+ ((? list?) (list (list type (cons 'list body))))))
+
+(define* (maybe-packages-field type package-names
+ #:optional (output #f))
+ "Given a list of PACKAGE-NAMES, tries to generate the TYPE field of a
+package definition."
+ (maybe-list-field type
+ (package-names->package-inputs package-names output)))
+
+(define* (maybe-inputs package-names #:optional (output #f))
+ "MAYBE-PACKAGES-FIELD for inputs."
+ (maybe-packages-field 'inputs package-names output))
(define* (maybe-native-inputs package-names #:optional (output #f))
- "Same as MAYBE-INPUTS, but for native inputs."
- (maybe-inputs package-names output #:type 'native))
+ "MAYBE-PACKAGES-FIELD for native inputs."
+ (maybe-packages-field 'native-inputs package-names output))
(define* (maybe-propagated-inputs package-names #:optional (output #f))
- "Same as MAYBE-INPUTS, but for propagated inputs."
- (maybe-inputs package-names output #:type 'propagated))
+ "MAYBE-PACKAGES-FIELD for propagated inputs."
+ (maybe-packages-field 'propagated-inputs package-names output))
(define* (package->definition guix-package #:optional append-version?/string)
"If APPEND-VERSION?/STRING is #t, append the package's major+minor version.
--
2.45.2
- [bug#70923] [PATCH v4 01/11] build-system: cargo: Accept unlabeled #:cargo-inputs., Herman Rimm, 2024/12/09
- [bug#70923] [PATCH v4 02/11] import: utils: Emit new-style package inputs.,
Herman Rimm <=
- [bug#70923] [PATCH v4 03/11] import: crate: Emit new-style package inputs., Herman Rimm, 2024/12/09
- [bug#70923] [PATCH v4 04/11] import: utils: Add 'maybe-upstream-inputs' procedure., Herman Rimm, 2024/12/09
- [bug#70923] [PATCH v4 07/11] import: hackage: Use 'maybe-list-field' procedure., Herman Rimm, 2024/12/09
- [bug#70923] [PATCH v4 06/11] import: elpa: Use maybe-propagated-inputs procedure., Herman Rimm, 2024/12/09
- [bug#70923] [PATCH v4 08/11] import: cran: Use 'maybe-list-field' procedure., Herman Rimm, 2024/12/09
- [bug#70923] [PATCH v4 10/11] import: egg: Use maybe-*inputs procedures., Herman Rimm, 2024/12/09
- [bug#70923] [PATCH v4 11/11] import: hexpm: Use (guix import utils) 'maybe-inputs' procedure., Herman Rimm, 2024/12/09
- [bug#70923] [PATCH v4 09/11] import: cpan: Use 'maybe-upstream-inputs' procedure., Herman Rimm, 2024/12/09