[PATCH 00/13] Add (guix import utils) procedures.

  • Open
  • quality assurance status badge
Details
3 participants
  • Efraim Flashner
  • Herman Rimm
  • Lars-Dominik Braun
Owner
unassigned
Submitted by
Herman Rimm
Severity
normal
H
H
Herman Rimm wrote on 13 May 21:59 +0200
(address . guix-patches@gnu.org)
cover.1715627497.git.herman@rimm.ee
Hello,

All but one importers (cran) now use procedures from (guix import utils)
to create the package inputs and arguments fields. I also made the
cargo build-system compatible with the new style of inputs.

[PATCH 02/13] and [PATCH 03/13] are based on commits from [bug#49531]
which were merged into the core-updates branch in January: [1] and [2]
respectively. The series is based on the master branch because I do not
think emitting and parsing the new style of cargo inputs is a major
change. I can prepare a patch series for core-updates based on [1] if
needed though.

For once I remove more lines of code than I add, yay!

Cheers,
Herman

[1]: 49a85411b2af0e324e3b70839acea2720e855b32
[2]: 71ef0d2216890c29cb77c7b3e2af4ce3b629d7b8

Herman Rimm (10):
build-system: cargo: Accept unlabeled #:cargo-inputs.
tests: elm: Adjust to new-style package inputs.
import: utils: Add 'maybe-upstream-inputs' procedure.
import: pypi: Use 'maybe-list-field' procedure.
import: elpa: Use maybe-propagated-inputs procedure.
import: hackage: Use 'maybe-list-field' procedure.
import: cran: Use 'maybe-list-field' procedure.
import: cpan: Use 'maybe-upstream-inputs' procedure.
import: egg: Use maybe-*inputs procedures.
import: hexpm: Use (guix import utils) 'maybe-inputs' procedure.

Sarah Morgensen (3):
import: utils: Emit new-style package inputs.
tests: go: Adjust to new-style package inputs.
import: crate: Emit new-style package inputs.

guix/build-system/cargo.scm | 12 +++-
guix/import/cpan.scm | 22 ++-----
guix/import/cran.scm | 35 +++++------
guix/import/crate.scm | 54 ++++++----------
guix/import/egg.scm | 38 +++---------
guix/import/elpa.scm | 9 +--
guix/import/hackage.scm | 38 ++++--------
guix/import/hexpm.scm | 20 ++----
guix/import/pypi.scm | 20 ++----
guix/import/utils.scm | 67 ++++++++++++--------
tests/crate.scm | 119 +++++++++++++++---------------------
tests/elm.scm | 4 +-
tests/go.scm | 2 +-
tests/hackage.scm | 13 ++--
14 files changed, 182 insertions(+), 271 deletions(-)


base-commit: 2793a79117d244b9e8fd48a8c3477f33f425210a
--
2.41.0
H
H
Herman Rimm wrote on 13 May 22:07 +0200
[PATCH 01/13] build-system: cargo: Accept unlabeled #:cargo-inputs.
(address . 70923@debbugs.gnu.org)
a6c9c6b0754eb8cafaefcc75f5119714bfcdb0d3.1715627497.git.herman@rimm.ee
* guix/build-system/cargo.scm (crate-closure): Match unlabeled inputs.

Change-Id: Iae421281fa08d09ddd1e5d2da2864f0093d97cd1
---
guix/build-system/cargo.scm | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

Toggle diff (25 lines)
diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index c029cc1dda..a918e25e7a 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -234,7 +234,17 @@ (define (crate-closure inputs)
(if (null? propagated)
(reverse result)
(loop (reverse (concatenate propagated)) result '() #f seen)))
- (((and input (label (? package? package))) rest ...)
+ (((? package? package) rest ...)
+ (if (and (not first?) (seen? seen package))
+ (loop rest result propagated first? seen)
+ (loop rest
+ (cons (list (package-name package) package) result)
+ (cons (package-cargo-inputs package)
+ propagated)
+ first?
+ (vhash-consq package package seen))))
+ ;; Match inputs with explicit labels for backward compatibility.
+ (((and input (_ (? package? package))) rest ...)
(if (and (not first?) (seen? seen package))
(loop rest result propagated first? seen)
(loop rest
--
2.41.0
H
H
Herman Rimm wrote on 13 May 22:07 +0200
[PATCH 02/13] import: utils: Emit new-style package inputs.
(address . 70923@debbugs.gnu.org)(name . Sarah Morgensen)(address . iskarian@mgsn.dev)
691df95b12c7f51c2c8ed5e0d495cb96cf3c7aa5.1715627497.git.herman@rimm.ee
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 | 58 ++++++++++++++++++++++++-------------------
1 file changed, 33 insertions(+), 25 deletions(-)

Toggle diff (95 lines)
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index 09a01cf315..1bbab916c4 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
@@ -409,41 +412,46 @@ (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)
- (cons* input (list 'unquote (string->symbol
- (if version
- (string-append input "-" version)
- input)))
- (or (and output (list output))
- '())))
+ (let ((symbol (string->symbol
+ (if version
+ (string-append input "-" version)
+ input))))
+ (if output
+ (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 (,'quasiquote ,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.41.0
H
H
Herman Rimm wrote on 13 May 22:08 +0200
[PATCH 03/13] tests: go: Adjust to new-style package inputs.
(address . 70923@debbugs.gnu.org)(name . Sarah Morgensen)(address . iskarian@mgsn.dev)
5e4fd3fd23307151ae51b1406a9554aa17ea1844.1715627497.git.herman@rimm.ee
From: Sarah Morgensen <iskarian@mgsn.dev>

* tests/go.scm ("go-module->guix-package"): Use new-style for
propagated-inputs.

Change-Id: Id6341bfb2d92c7f1d7fb85e46d38748584e5fabe
---
tests/go.scm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Toggle diff (15 lines)
diff --git a/tests/go.scm b/tests/go.scm
index d2e8846b30..f925c485c1 100644
--- a/tests/go.scm
+++ b/tests/go.scm
@@ -389,7 +389,7 @@ (define (mock-http-get testcase)
(arguments
(list #:import-path "github.com/go-check/check"))
(propagated-inputs
- `(("go-github-com-kr-pretty" ,go-github-com-kr-pretty)))
+ (list go-github-com-kr-pretty))
(home-page "https://github.com/go-check/check")
(synopsis "Instructions")
(description "Package check is a rich testing extension for Go's testing \
--
2.41.0
H
H
Herman Rimm wrote on 13 May 22:08 +0200
[PATCH 04/13] tests: elm: Adjust to new-style package inputs.
(address . 70923@debbugs.gnu.org)
6616ae10b267f38a3cfa8aaef9fc0bd0f913fd30.1715627497.git.herman@rimm.ee
* tests/elm.scm ("elm-recursive-import \"elm-guix/demo\""): Use
the new-style for inputs and propagated-inputs.

Change-Id: Iae05b5e9f9b6a73cb2d08bb3b0f73df9004f83ac
---
tests/elm.scm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Toggle diff (18 lines)
diff --git a/tests/elm.scm b/tests/elm.scm
index c30623da03..2cdeab96fb 100644
--- a/tests/elm.scm
+++ b/tests/elm.scm
@@ -250,9 +250,9 @@ (define (directory-sha256 directory)
(base32 ,(? string? hash))))
(build-system elm-build-system)
(propagated-inputs
- ,'`(("elm-core" ,elm-core)))
+ (list elm-core))
(inputs
- ,'`(("elm-json" ,elm-json)))
+ (list elm-json))
(home-page
"https://package.elm-lang.org/packages/elm-guix/demo/3.0.0")
(synopsis "A test for `(guix import elm)`")
--
2.41.0
H
H
Herman Rimm wrote on 13 May 22:08 +0200
[PATCH 06/13] import: utils: Add 'maybe-upstream-inputs' procedure.
(address . 70923@debbugs.gnu.org)
162a6f222e11f72a5eaa8246c4f03c494f0440ca.1715627497.git.herman@rimm.ee
* guix/import/utils.scm (maybe-upstream-inputs): Add procedure.

Change-Id: Ib8a80216d512c0373e55e4f27e1ef2a7c1fb854a
---
guix/import/utils.scm | 9 +++++++++
1 file changed, 9 insertions(+)

Toggle diff (36 lines)
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index 1bbab916c4..98080dd0a0 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -45,6 +45,7 @@ (define-module (guix import utils)
#:use-module (guix download)
#:use-module (guix sets)
#:use-module ((guix ui) #:select (fill-paragraph))
+ #:use-module (guix upstream)
#:use-module (gnu packages)
#:autoload (ice-9 control) (let/ec)
#:use-module (ice-9 match)
@@ -71,6 +72,7 @@ (define-module (guix import utils)
maybe-inputs
maybe-native-inputs
maybe-propagated-inputs
+ maybe-upstream-inputs
package->definition
spdx-string->license
@@ -453,6 +455,13 @@ (define* (maybe-propagated-inputs package-names #:optional (output #f))
"MAYBE-PACKAGES-FIELD for propagated inputs."
(maybe-packages-field 'propagated-inputs package-names output))
+(define* (maybe-upstream-inputs type upstream-inputs)
+ "Given a list of UPSTREAM-NAMES, tries to generate the TYPE field of a
+package definition."
+ (maybe-list-field type
+ (map (compose string->symbol upstream-input-downstream-name)
+ upstream-inputs)))
+
(define* (package->definition guix-package #:optional append-version?/string)
"If APPEND-VERSION?/STRING is #t, append the package's major+minor version.
If it is the symbol 'full, append the package's complete version. If
--
2.41.0
H
H
Herman Rimm wrote on 13 May 22:08 +0200
[PATCH 05/13] import: crate: Emit new-style package inputs.
(address . 70923@debbugs.gnu.org)(name . Sarah Morgensen)(address . iskarian@mgsn.dev)
c8a62db4b34bb7d9a70a39c83c95ef23f77d38c9.1715627497.git.herman@rimm.ee
From: Sarah Morgensen <iskarian@mgsn.dev>

* guix/import/crate.scm (maybe-cargo-inputs,
maybe-cargo-development-inputs, maybe-arguments): Delete procedures.
(make-crate-sexp): Add 'unwrap' procedure, use with maybe-packages-field
and fix indentation.
* tests/crate.scm: Adjust accordingly.

Change-Id: Ie8debd2553a338c3c623162b843e0a9827314074
---
guix/import/crate.scm | 54 +++++++------------
tests/crate.scm | 119 +++++++++++++++++-------------------------
2 files changed, 68 insertions(+), 105 deletions(-)

Toggle diff (317 lines)
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 7a25b2243c..760c5f0de4 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -7,6 +7,8 @@
;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2023, 2024 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2023, 2024 David Elsing <david.elsing@posteo.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -141,27 +143,6 @@ (define (crate-version-dependencies version)
;;; Converting crates to Guix packages.
;;;
-(define (maybe-cargo-inputs package-names)
- (match (package-names->package-inputs package-names)
- (()
- '())
- ((package-inputs ...)
- `(#:cargo-inputs ,package-inputs))))
-
-(define (maybe-cargo-development-inputs package-names)
- (match (package-names->package-inputs package-names)
- (()
- '())
- ((package-inputs ...)
- `(#:cargo-development-inputs ,package-inputs))))
-
-(define (maybe-arguments arguments)
- (match arguments
- (()
- '())
- ((args ...)
- `((arguments (,'quasiquote ,args))))))
-
(define (version->semver-prefix version)
"Return the version up to and including the first non-zero part"
(first
@@ -185,8 +166,14 @@ (define* (make-crate-sexp #:key name version cargo-inputs cargo-development-inpu
(let* ((port (http-fetch (crate-uri name version)))
(guix-name (crate-name->package-name name))
- (cargo-inputs (format-inputs cargo-inputs))
- (cargo-development-inputs (format-inputs cargo-development-inputs))
+ (unwrap (match-lambda
+ ((lst) lst)
+ (() '())))
+ (cargo-inputs (maybe-packages-field '#:cargo-inputs
+ (format-inputs cargo-inputs)))
+ (cargo-development-inputs
+ (maybe-packages-field '#:cargo-development-inputs
+ (format-inputs cargo-development-inputs)))
(pkg `(package
(name ,guix-name)
(version ,version)
@@ -204,12 +191,12 @@ (define* (make-crate-sexp #:key name version cargo-inputs cargo-development-inpu
`((properties '((crate-version-yanked? . #t))))
'())
(build-system cargo-build-system)
- ,@(maybe-arguments (append (if build?
- '()
- '(#:skip-build? #t))
- (maybe-cargo-inputs cargo-inputs)
- (maybe-cargo-development-inputs
- cargo-development-inputs)))
+ ,@(maybe-list-field 'arguments
+ (append (if build?
+ '()
+ '(#:skip-build? #t))
+ (unwrap cargo-inputs)
+ (unwrap cargo-development-inputs)))
(home-page ,home-page)
(synopsis ,synopsis)
(description ,(beautify-description description))
@@ -218,11 +205,10 @@ (define* (make-crate-sexp #:key name version cargo-inputs cargo-development-inpu
(#f #f)
((license) license)
(_ `(list ,@license)))))))
- (close-port port)
- (package->definition pkg
- (if yanked?
- (string-append version "-yanked")
- (version->semver-prefix version)))))
+ (close-port port)
+ (package->definition pkg (if yanked?
+ (string-append version "-yanked")
+ (version->semver-prefix version)))))
(define (string->license string)
(filter-map (lambda (license)
diff --git a/tests/crate.scm b/tests/crate.scm
index ce2f08aade..7651a5b5bb 100644
--- a/tests/crate.scm
+++ b/tests/crate.scm
@@ -5,6 +5,8 @@
;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
;;; Copyright © 2023 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2023 David Elsing <david.elsing@posteo.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -497,10 +499,10 @@ (define have-guile-semver?
(? string? hash)))))
(build-system 'cargo-build-system)
(arguments
- ('quasiquote
- (#:skip-build? #t
+ (list
+ #:skip-build? #t
#:cargo-inputs
- (("rust-leaf-alice" ('unquote 'rust-leaf-alice-0.7))))))
+ (list rust-leaf-alice-0.7)))
(home-page "http://example.com")
(synopsis "summary")
(description "summary")
@@ -589,7 +591,7 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:skip-build? #t)))
+ (list #:skip-build? #t))
(home-page "http://example.com")
(synopsis "summary")
(description "summary")
@@ -608,7 +610,7 @@ (define have-guile-semver?
(base32
(? string? hash)))))
(build-system cargo-build-system)
- (arguments ('quasiquote (#:skip-build? #t)))
+ (arguments (list #:skip-build? #t))
(home-page "http://example.com")
(synopsis "summary")
(description "summary")
@@ -627,7 +629,7 @@ (define have-guile-semver?
(base32
(? string? hash)))))
(build-system cargo-build-system)
- (arguments ('quasiquote (#:skip-build? #t)))
+ (arguments (list #:skip-build? #t))
(home-page "http://example.com")
(synopsis "summary")
(description "summary")
@@ -647,10 +649,9 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:skip-build? #t
- #:cargo-inputs
- (("rust-leaf-bob"
- ('unquote rust-leaf-bob-3))))))
+ (list #:skip-build? #t
+ #:cargo-inputs
+ (list rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "summary")
@@ -670,14 +671,11 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:skip-build? #t
- #:cargo-inputs
- (("rust-intermediate-b"
- ('unquote rust-intermediate-b-1))
- ("rust-leaf-alice"
- ('unquote 'rust-leaf-alice-0.7))
- ("rust-leaf-bob"
- ('unquote rust-leaf-bob-3))))))
+ (list #:skip-build? #t
+ #:cargo-inputs
+ (list rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "summary")
@@ -697,18 +695,13 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-intermediate-a"
- ('unquote rust-intermediate-a-1))
- ("rust-intermediate-b"
- ('unquote rust-intermediate-b-1))
- ("rust-leaf-alice"
- ('unquote 'rust-leaf-alice-0.7))
- ("rust-leaf-bob"
- ('unquote rust-leaf-bob-3)))
- #:cargo-development-inputs
- (("rust-intermediate-c"
- ('unquote rust-intermediate-c-1))))))
+ (list #:cargo-inputs
+ (list rust-intermediate-a-1
+ rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)
+ #:cargo-development-inputs
+ ((list rust-intermediate-c-1))))
(home-page "http://example.com")
(synopsis "summary")
(description "summary")
@@ -735,9 +728,8 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-development-inputs
- (("rust-leaf-alice"
- ('unquote rust-leaf-alice-0.7))))))
+ (list #:cargo-development-inputs
+ (list rust-leaf-alice-0.7)))
(home-page "http://example.com")
(synopsis "summary")
(description "summary")
@@ -793,9 +785,8 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-leaf-bob"
- ('unquote rust-leaf-bob-3))))))
+ (list #:cargo-inputs
+ (list rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "summary")
@@ -815,13 +806,10 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-intermediate-b"
- ('unquote rust-intermediate-b-1))
- ("rust-leaf-alice"
- ('unquote 'rust-leaf-alice-0.7))
- ("rust-leaf-bob"
- ('unquote rust-leaf-bob-3))))))
+ (list #:cargo-inputs
+ (list rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "summary")
@@ -841,18 +829,13 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-intermediate-a"
- ('unquote rust-intermediate-a-1))
- ("rust-intermediate-b"
- ('unquote rust-intermediate-b-1))
- ("rust-leaf-alice"
- ('unquote 'rust-leaf-alice-0.7))
- ("rust-leaf-bob"
- ('unquote rust-leaf-bob-3)))
- #:cargo-development-inputs
- (("rust-intermediate-c"
- ('unquote rust-intermediate-c-1))))))
+ (list #:cargo-inputs
+ (list rust-intermediate-a-1
+ rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)
+ #:cargo-development-inputs
+ (list rust-intermediate-c-1)))
(home-page "http://example.com")
(synopsis "summary")
(description "summary")
@@ -962,14 +945,11 @@ (define rust-leaf-bob-3.0.2-yanked
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-3)))
- #:cargo-development-inputs
- (("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-3.0.2-yanked))
- ("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-4.0.0-yanked))))))
+ (list #:cargo-inputs
+ (list rust-leaf-bob-3)
+ #:cargo-development-inputs
+ (list rust-leaf-bob-3.0.2-yanked
+ rust-leaf-bob-4.0.0-yanked)))
(home-page "http://example.com")
(synopsis "summary")
(description "summary")
@@ -1093,14 +1073,11 @@ (define rust-leaf-bob-3.0.2-yanked
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-3)))
- #:cargo-development-inputs
- (("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-3.0.2-yanked))
- ("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-4.0.0-yanked))))))
+ (list #:cargo-inputs
+ (list rust-leaf-bob-3)
+ #:cargo-development-inputs
+ (list rust-leaf-bob-3.0.2-yanked
+ rust-leaf-bob-4.0.0-yanked)))
(home-page "http://example.com")
(synopsis "summary")
(description "summary")
--
2.41.0
H
H
Herman Rimm wrote on 13 May 22:08 +0200
[PATCH 07/13] import: pypi: Use 'maybe-list-field' procedure.
(address . 70923@debbugs.gnu.org)
210d22fd9d577748a23093df1e162a36373688a6.1715627497.git.herman@rimm.ee
* guix/import/pypi.scm (maybe-inputs): Delete procedure.
(make-pypi-sexp): Use 'maybe-list-field' and 'maybe-upstream-inputs'
procedures.
---
guix/import/pypi.scm | 20 ++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)

Toggle diff (40 lines)
diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm
index 6719fde330..c46f8897b9 100644
--- a/guix/import/pypi.scm
+++ b/guix/import/pypi.scm
@@ -201,18 +201,6 @@ (define (wheel-url->extracted-directory wheel-url)
((name version _ ...)
(string-append name "-" version ".dist-info"))))
-(define (maybe-inputs package-inputs input-type)
- "Given a list of PACKAGE-INPUTS, tries to generate the 'inputs' field of a
-package definition. INPUT-TYPE, a symbol, is used to populate the name of
-the input field."
- (match package-inputs
- (()
- '())
- ((package-inputs ...)
- `((,input-type (list ,@(map (compose string->symbol
- upstream-input-downstream-name)
- package-inputs)))))))
-
(define %requirement-name-regexp
;; Regexp to match the requirement name in a requirement specification.
@@ -538,10 +526,10 @@ (define* (make-pypi-sexp pypi-package
bytevector->nix-base32-string)))))
,@(maybe-upstream-name name)
(build-system pyproject-build-system)
- ,@(maybe-inputs (upstream-source-propagated-inputs source)
- 'propagated-inputs)
- ,@(maybe-inputs (upstream-source-native-inputs source)
- 'native-inputs)
+ ,@(maybe-upstream-inputs 'propagated-inputs
+ (upstream-source-propagated-inputs source))
+ ,@(maybe-upstream-inputs 'native-inputs
+ (upstream-source-native-inputs source))
(home-page ,(project-info-home-page info))
(synopsis ,(project-info-summary info))
(description ,(beautify-description
--
2.41.0
H
H
Herman Rimm wrote on 13 May 22:08 +0200
[PATCH 08/13] import: elpa: Use maybe-propagated-inputs procedure.
(address . 70923@debbugs.gnu.org)
e044fef16bc6a3d5afd0a2b0722a518eb06a6a78.1715627497.git.herman@rimm.ee
* guix/import/elpa.scm (maybe-inputs): Delete procedure.
(elpa-package->sexp): Use maybe-propagated-inputs procedure.

Change-Id: I9b40e9d387311f5dbbb079938733bf945a1a6ee6
---
guix/import/elpa.scm | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)

Toggle diff (29 lines)
diff --git a/guix/import/elpa.scm b/guix/import/elpa.scm
index d1855b3698..0072500155 100644
--- a/guix/import/elpa.scm
+++ b/guix/import/elpa.scm
@@ -358,13 +358,6 @@ (define* (elpa-package->sexp pkg #:optional license repo)
(map (compose string->symbol elpa-name->package-name)
dependencies-names))
- (define (maybe-inputs input-type inputs)
- (match inputs
- (()
- '())
- ((inputs ...)
- (list (list input-type `(list ,@inputs))))))
-
(define melpa-source
(melpa-recipe->origin melpa-recipe))
@@ -385,7 +378,7 @@ (define* (elpa-package->sexp pkg #:optional license repo)
(file-hash* tarball #:recursive? #false))
"failed to download package")))))))
(build-system emacs-build-system)
- ,@(maybe-inputs 'propagated-inputs dependencies)
+ ,@(maybe-propagated-inputs dependencies)
,@(if melpa-source
(melpa-recipe->maybe-arguments melpa-recipe)
'())
--
2.41.0
H
H
Herman Rimm wrote on 13 May 22:08 +0200
[PATCH 10/13] import: cran: Use 'maybe-list-field' procedure.
(address . 70923@debbugs.gnu.org)
dfe6ea71b8f3c8252e34887ab965e54745a47e3d.1715627497.git.herman@rimm.ee
* guix/import/cran.scm (format-inputs): Delete procedure.
(maybe-inputs): Use 'maybe-list-field' procedure.

Change-Id: I5148afcebdac1f7fa0f8cce9e82e8cebb56c36c8
---
guix/import/cran.scm | 35 +++++++++++++++--------------------
1 file changed, 15 insertions(+), 20 deletions(-)

Toggle diff (55 lines)
diff --git a/guix/import/cran.scm b/guix/import/cran.scm
index 6ae00cae96..70ee3eb9ec 100644
--- a/guix/import/cran.scm
+++ b/guix/import/cran.scm
@@ -85,21 +85,6 @@ (define-module (guix import cran)
(define %input-style
(make-parameter 'variable)) ; or 'specification
-(define (format-inputs inputs)
- "Generate a sorted list of package inputs from a list of upstream inputs."
- (map (lambda (input)
- (case (%input-style)
- ((specification)
- `(specification->package ,(upstream-input-downstream-name input)))
- (else
- ((compose string->symbol
- upstream-input-downstream-name)
- input))))
- (sort inputs
- (lambda (a b)
- (string-ci<? (upstream-input-name a)
- (upstream-input-name b))))))
-
(define (string->licenses license-string license-prefix)
(let ((licenses
(map string-trim-both
@@ -188,11 +173,21 @@ (define (description->alist description)
(define* (maybe-inputs package-inputs #:optional (input-type 'inputs))
"Given a list of PACKAGE-INPUTS, tries to generate the TYPE field of a
package definition."
- (match package-inputs
- (()
- '())
- ((package-inputs ...)
- `((,input-type (list ,@(format-inputs package-inputs)))))))
+ (define (format-input input)
+ (case (%input-style)
+ ((specification)
+ `(specification->package ,(upstream-input-downstream-name input)))
+ (else
+ ((compose string->symbol
+ upstream-input-downstream-name)
+ input))))
+
+ (define (upstream-input-name<? i1 i2)
+ (string-ci<? (upstream-input-name i1)
+ (upstream-input-name i2)))
+
+ (maybe-list-field input-type
+ (map format-input (sort package-inputs upstream-input-name<?))))
(define %cran-url "https://cloud.r-project.org/web/packages/")
(define %cran-canonical-url "https://cran.r-project.org/package=")
--
2.41.0
H
H
Herman Rimm wrote on 13 May 22:08 +0200
[PATCH 09/13] import: hackage: Use 'maybe-list-field' procedure.
(address . 70923@debbugs.gnu.org)
42bfac7c486b9dd94633eddb348cb97c3a47bd43.1715627497.git.herman@rimm.ee
* guix/import/hackage.scm (maybe-inputs, maybe-arguments): Delete
procedures.
(hackage-module->sexp): Use 'maybe-list-field' and
'maybe-upstream-inputs' procedures.
* tests/hackage.scm: Fix whitespace and replace 'quasiquote' with
'list'.

Change-Id: I4fe39ff84c9f6a677f810d9e4fe751d762973757
---
guix/import/hackage.scm | 38 +++++++++++---------------------------
tests/hackage.scm | 13 +++++++------
2 files changed, 18 insertions(+), 33 deletions(-)

Toggle diff (110 lines)
diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm
index 79a51d3300..e90f3c932f 100644
--- a/guix/import/hackage.scm
+++ b/guix/import/hackage.scm
@@ -288,26 +288,6 @@ (define* (hackage-module->sexp cabal cabal-hash
#:include-test-dependencies?
include-test-dependencies?))
- (define (maybe-inputs input-type inputs)
- (match inputs
- (()
- '())
- ((inputs ...)
- (list (list input-type
- `(list ,@(map (compose string->symbol
- upstream-input-downstream-name)
- inputs)))))))
-
- (define (maybe-arguments)
- (match (append (if (not include-test-dependencies?)
- '(#:tests? #f)
- '())
- (if (not (string-null? revision))
- `(#:cabal-revision (,revision ,cabal-hash))
- '()))
- (() '())
- (args `((arguments (,'quasiquote ,args))))))
-
(let ((tarball (with-store store
(download-to-store store source-url))))
(values
@@ -324,13 +304,17 @@ (define* (hackage-module->sexp cabal cabal-hash
"failed to download tar archive")))))
(build-system haskell-build-system)
(properties '((upstream-name . ,name)))
- ,@(maybe-inputs 'inputs
- (filter (upstream-input-type-predicate 'regular)
- inputs))
- ,@(maybe-inputs 'native-inputs
- (filter (upstream-input-type-predicate 'native)
- inputs))
- ,@(maybe-arguments)
+ ,@(maybe-upstream-inputs 'inputs
+ (filter (upstream-input-type-predicate 'regular) inputs))
+ ,@(maybe-upstream-inputs 'native-inputs
+ (filter (upstream-input-type-predicate 'native) inputs))
+ ,@(maybe-list-field 'arguments
+ (append (if (not include-test-dependencies?)
+ '(#:tests? #f)
+ '())
+ (if (not (string-null? revision))
+ `(#:cabal-revision '(,revision ,cabal-hash))
+ '())))
(home-page ,(cabal-package-home-page cabal))
(synopsis ,(cabal-package-synopsis cabal))
(description ,(beautify-description (cabal-package-description cabal)))
diff --git a/tests/hackage.scm b/tests/hackage.scm
index 403f587c41..f6d91515e2 100644
--- a/tests/hackage.scm
+++ b/tests/hackage.scm
@@ -67,7 +67,7 @@ (define test-cabal-3
if impl(ghc>=7.2&&<7.6)
Build-depends: ghc-b
if impl(ghc == 7.8)
- Build-depends:
+ Build-depends:
HTTP >= 4000.2.5 && < 4000.3,
mtl >= 2.0 && < 3
")
@@ -86,7 +86,7 @@ (define test-cabal-4
if impl(ghc>=7.2&&<7.6)
Build-depends: ghc-b
if impl(ghc == 7.8)
- Build-depends:
+ Build-depends:
HTTP >= 4000.2.5 && < 4000.3,
mtl >= 2.0 && < 3
")
@@ -101,7 +101,7 @@ (define test-cabal-5
license: BSD3
library
if impl(ghc == 7.8)
- Build-depends:
+ Build-depends:
HTTP >= 4000.2.5 && < 4000.3,
if impl(ghc -any)
Build-depends: mtl >= 2.0 && < 3
@@ -126,7 +126,7 @@ (define test-cabal-6
if impl(ghc>=7.2&&<7.6)
Build-depends: ghc-b
if impl(ghc == 7.8)
- Build-depends:
+ Build-depends:
HTTP >= 4000.2.5 && < 4000.3,
mtl >= 2.0 && < 3
")
@@ -524,8 +524,9 @@ (define-package-matcher match-ghc-foo-revision
('properties '(quote ((upstream-name . "foo"))))
('inputs ('list 'ghc-http))
('arguments
- ('quasiquote
- ('#:cabal-revision
+ ('list
+ '#:cabal-revision
+ ('quote
("2" "0xxd88fb659f0krljidbvvmkh9ppjnx83j0nqzx8whcg4n5qbyng"))))
('home-page "http://test.org")
('synopsis (? string?))
--
2.41.0
H
H
Herman Rimm wrote on 13 May 22:08 +0200
[PATCH 12/13] import: egg: Use maybe-*inputs procedures.
(address . 70923@debbugs.gnu.org)
b76a96469519cc553524c0d18f13c32992d39838.1715627497.git.herman@rimm.ee
* guix/import/egg.scm (maybe-inputs): Delete procedure.
(egg-parse-dependency): Simplify procedure to return strings.
(egg->guix-package): Use maybe-*inputs procedures.

Change-Id: Ib0a3f5b6f02912c847defd02ba7675d80005279b
---
guix/import/egg.scm | 38 ++++++++++----------------------------
1 file changed, 10 insertions(+), 28 deletions(-)

Toggle diff (73 lines)
diff --git a/guix/import/egg.scm b/guix/import/egg.scm
index e3bc158475..60e1eef156 100644
--- a/guix/import/egg.scm
+++ b/guix/import/egg.scm
@@ -229,23 +229,14 @@ (define* (egg->guix-package name version #:key (file #f) (source #f)
(else char)))
(maybe-symbol->string name)))
- (define* (egg-parse-dependency name #:key (system? #f))
- (define extract-name
- (match-lambda
- ((name version) name)
- (name name)))
-
- (define (prettify-name name)
+ (define* (egg-parse-dependency dependency #:key (system? #f))
+ (let ((name (match dependency
+ ((name version) name)
+ (name name))))
(if system?
(prettify-system-dependency name)
- (maybe-symbol->string name)))
-
- (let ((name (prettify-name (extract-name name))))
- ;; Dependencies are sometimes specified as symbols and sometimes
- ;; as strings
- (string->symbol (string-append
- (if system? "" package-name-prefix)
- name))))
+ (string-append package-name-prefix
+ (maybe-symbol->string name)))))
(define egg-propagated-inputs
(let ((dependencies (assoc-ref egg-content 'dependencies)))
@@ -277,15 +268,6 @@ (define* (egg->guix-package name version #:key (file #f) (source #f)
test+build-dependencies))
(() '()))))
- ;; Copied from (guix import hackage).
- (define (maybe-inputs input-type inputs)
- (match inputs
- (()
- '())
- ((inputs ...)
- (list (list input-type
- `(list ,@inputs))))))
-
(values
`(package
(name ,(egg-name->guix-name name))
@@ -303,16 +285,16 @@ (define* (egg->guix-package name version #:key (file #f) (source #f)
"failed to download tar archive"))))))
(build-system chicken-build-system)
(arguments ,(list 'quasiquote (list #:egg-name name)))
- ,@(maybe-inputs 'native-inputs egg-native-inputs)
- ,@(maybe-inputs 'inputs egg-inputs)
- ,@(maybe-inputs 'propagated-inputs egg-propagated-inputs)
+ ,@(maybe-native-inputs egg-native-inputs)
+ ,@(maybe-inputs egg-inputs)
+ ,@(maybe-propagated-inputs egg-propagated-inputs)
(home-page ,egg-home-page)
(synopsis ,egg-synopsis)
(description #f)
(license ,egg-licenses))
(filter (lambda (name)
(not (member name '("srfi-4"))))
- (map (compose guix-name->egg-name symbol->string)
+ (map guix-name->egg-name
(append egg-propagated-inputs
egg-native-inputs)))))))
--
2.41.0
H
H
Herman Rimm wrote on 13 May 22:08 +0200
[PATCH 11/13] import: cpan: Use 'maybe-upstream-inputs' procedure.
(address . 70923@debbugs.gnu.org)
40e6e376621412e26b576fc8aab96caa78274a52.1715627497.git.herman@rimm.ee
* guix/import/cpan.scm (maybe-inputs): Delete procedure.
(cpan-module->sexp): Use 'maybe-upstream-inputs' procedure.

Change-Id: I4fa99da62d81f02c2998ad96f5ea81e27df071cd
---
guix/import/cpan.scm | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)

Toggle diff (49 lines)
diff --git a/guix/import/cpan.scm b/guix/import/cpan.scm
index b87736eef6..55c616314b 100644
--- a/guix/import/cpan.scm
+++ b/guix/import/cpan.scm
@@ -37,7 +37,8 @@ (define-module (guix import cpan)
#:use-module (guix utils)
#:use-module (guix base32)
#:use-module ((guix download) #:select (download-to-store url-fetch))
- #:use-module ((guix import utils) #:select (factorize-uri))
+ #:use-module ((guix import utils) #:select (factorize-uri
+ maybe-upstream-inputs))
#:use-module (guix import json)
#:use-module (guix packages)
#:use-module (guix upstream)
@@ -275,15 +276,6 @@ (define (cpan-module->sexp release)
(define version (cpan-release-version release))
(define source-url (cpan-source-url release))
- (define (maybe-inputs input-type inputs)
- (match inputs
- (()
- '())
- ((inputs ...)
- `((,input-type (list ,@(map (compose string->symbol
- upstream-input-downstream-name)
- inputs)))))))
-
(let ((tarball (with-store store
(download-to-store store source-url)))
(inputs (cpan-module-inputs release)))
@@ -297,12 +289,10 @@ (define (cpan-module->sexp release)
(base32
,(bytevector->nix-base32-string (file-sha256 tarball))))))
(build-system perl-build-system)
- ,@(maybe-inputs 'native-inputs
- (filter (upstream-input-type-predicate 'native)
- inputs))
- ,@(maybe-inputs 'propagated-inputs
- (filter (upstream-input-type-predicate 'propagated)
- inputs))
+ ,@(maybe-upstream-inputs 'native-inputs
+ (filter (upstream-input-type-predicate 'native) inputs))
+ ,@(maybe-upstream-inputs 'propagated-inputs
+ (filter (upstream-input-type-predicate 'propagated) inputs))
(home-page ,(cpan-home name))
(synopsis ,(cpan-release-abstract release))
(description fill-in-yourself!)
--
2.41.0
H
H
Herman Rimm wrote on 13 May 22:08 +0200
[PATCH 13/13] import: hexpm: Use (guix import utils) 'maybe-inputs' procedure.
(address . 70923@debbugs.gnu.org)
65ea14e719d9219414bc635feee982b8e4857a5a.1715627497.git.herman@rimm.ee
* guix/import/hexpm.scm (maybe-inputs): Delete procedure.
(dependencies->package-names): Return strings instead of symbols.
(make-hexpm-sexp): Use 'maybe-inputs' from (guix import utils).

Change-Id: Ie7a8a630a3a9d4859453d49fdee42aa560e27f17
---
guix/import/hexpm.scm | 20 ++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)

Toggle diff (45 lines)
diff --git a/guix/import/hexpm.scm b/guix/import/hexpm.scm
index 71a54ba973..af7a96efb0 100644
--- a/guix/import/hexpm.scm
+++ b/guix/import/hexpm.scm
@@ -153,26 +153,14 @@ (define (lookup-hexpm-release version*)
;;; Converting hex.pm packages to Guix packages.
;;;
-(define (maybe-inputs package-inputs input-type)
- "Given a list of PACKAGE-INPUTS, tries to generate the 'inputs' field of a
-package definition. INPUT-TYPE, a symbol, is used to populate the name of
-the input field."
- (match package-inputs
- (()
- '())
- ((package-inputs ...)
- `((,input-type (list ,@package-inputs))))))
-
(define (dependencies->package-names names)
- "Given a list of hexpm package NAMES, returns a list of guix package names
-as symbols."
+ "Given a list of hexpm package NAMES, returns a list of guix package
+names."
;; TODO: Base name on language of dependency.
;; The language used for implementing the dependency is not know without
;; recursing the dependencies. So for now assume more packages are based on
;; Erlang and prefix all dependencies with "erlang-" (the default).
- (map string->symbol
- (map hexpm-name->package-name
- (sort names string-ci<?))))
+ (map hexpm-name->package-name (sort names string-ci<?)))
(define* (make-hexpm-sexp #:key name version tarball-url
home-page synopsis description license
@@ -194,7 +182,7 @@ (define* (make-hexpm-sexp #:key name version tarball-url
(uri (hexpm-uri ,name version))
(sha256 (base32 ,(guix-hash-url temp)))))
(build-system ,build-system)
- ,@(maybe-inputs (dependencies->package-names dependencies) 'inputs)
+ ,@(maybe-inputs (dependencies->package-names dependencies))
(synopsis ,synopsis)
(description ,(beautify-description description))
(home-page ,(match home-page
--
2.41.0
H
H
Herman Rimm wrote on 4 Sep 22:32 +0200
[PATCH v2 01/12] build-system: cargo: Accept unlabeled #:cargo-inputs.
(address . 70923@debbugs.gnu.org)
20240904203309.23715-1-herman@rimm.ee
* guix/build-system/cargo.scm (crate-closure): Match unlabeled inputs.

Change-Id: Iae421281fa08d09ddd1e5d2da2864f0093d97cd1
---
guix/build-system/cargo.scm | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

Toggle diff (42 lines)
diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 658a2e525e..2e3061c0e8 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -6,6 +6,7 @@
;;; Copyright © 2019 Ivan Petkov <ivanppetkov@gmail.com>
;;; Copyright © 2020 Jakub K?dzio?ka <kuba@kadziolka.net>
;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -234,11 +235,14 @@ (define (seen? seen item)
(if (null? propagated)
(reverse result)
(loop (reverse (concatenate propagated)) result '() #f seen)))
- (((and input (label (? package? package))) rest ...)
+ ;; Match inputs with labels for backward compatibility.
+ (((or (_ (? package? package))
+ (? package? package))
+ rest ...)
(if (and (not first?) (seen? seen package))
(loop rest result propagated first? seen)
(loop rest
- (cons input result)
+ (cons package result)
(cons (package-cargo-inputs package)
propagated)
first?
@@ -296,8 +300,8 @@ (define (expand-crate-sources cargo-inputs cargo-development-inputs)
something that can always be extended or reworked in the future)."
(filter-map
(match-lambda
- ((label (? package? p))
- (list label (package-source p)))
+ ((? package? p)
+ (list (package-name p) (package-source p)))
((label input)
(list label input)))
(crate-closure (append cargo-inputs cargo-development-inputs))))
--
2.45.2
H
H
Herman Rimm wrote on 4 Sep 22:32 +0200
[PATCH v2 02/12] import: utils: Emit new-style inputs from maybe-*inputs procedures.
(address . 70923@debbugs.gnu.org)
20240904203309.23715-2-herman@rimm.ee
* guix/import/utils.scm (package-names->package-inputs)[make-input]:
Refactor.
(maybe-list-field): Add procedure, which wraps BODY in 'list' instead of
'quasiquote'.
(maybe-packages-field): Add procedure.
(maybe-inputs, maybe-native-inputs, maybe-propagated-inputs): Use
maybe-packages-field.

Change-Id: I66588f4c822d507ddbaf465a268bfb71af8a7ecd
---
guix/import/utils.scm | 54 +++++++++++++++++++++++++------------------
1 file changed, 31 insertions(+), 23 deletions(-)

Toggle diff (91 lines)
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index b7756fcc40..75bef1e9c7 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
@@ -418,39 +421,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)))
- (if output
- (list (string->symbol name) output)
- (string->symbol name))))
+ (let ((symbol (string->symbol
+ (if version
+ (string-append input "-" version)
+ input))))
+ (if output (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
H
H
Herman Rimm wrote on 4 Sep 22:32 +0200
[PATCH v2 03/12] tests: elm: Adjust to new-style package inputs.
(address . 70923@debbugs.gnu.org)
20240904203309.23715-3-herman@rimm.ee
* tests/elm.scm (elm-recursive-import "elm-guix/demo"): Use
the new-style for inputs and propagated-inputs.

Change-Id: Iae05b5e9f9b6a73cb2d08bb3b0f73df9004f83ac
---
tests/elm.scm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Toggle diff (18 lines)
diff --git a/tests/elm.scm b/tests/elm.scm
index 48d3eb4b01..7de2168665 100644
--- a/tests/elm.scm
+++ b/tests/elm.scm
@@ -250,9 +250,9 @@ (define elm-guix-demo-dir
(base32 ,(? string? hash))))
(build-system elm-build-system)
(propagated-inputs
- ,'`(("elm-core" ,elm-core)))
+ (list elm-core))
(inputs
- ,'`(("elm-json" ,elm-json)))
+ (list elm-json))
(home-page
"https://package.elm-lang.org/packages/elm-guix/demo/3.0.0")
(synopsis "A test for `(guix import elm)`")
--
2.45.2
H
H
Herman Rimm wrote on 4 Sep 22:32 +0200
[PATCH v2 04/12] import: crate: Use (guix import utils) procedures.
(address . 70923@debbugs.gnu.org)
20240904203309.23715-4-herman@rimm.ee
* guix/import/crate.scm (maybe-cargo-inputs,
maybe-cargo-development-inputs, maybe-arguments): Delete procedures.
(make-crate-sexp): Add 'unwrap' procedure, use with maybe-packages-field
and fix indentation.
* tests/crate.scm: Replace quasiquotes with list procedures.
---
guix/import/crate.scm | 53 +++++++++---------------
tests/crate.scm | 94 +++++++++++++++++++++----------------------
2 files changed, 66 insertions(+), 81 deletions(-)

Toggle diff (291 lines)
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 263c2a8b16..e451ebee68 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -8,6 +8,7 @@
;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2023, 2024 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2023, 2024 David Elsing <david.elsing@posteo.net>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -159,27 +160,6 @@ (define (make-input input version)
(input (make-input input #f)))
names))
-(define (maybe-cargo-inputs package-names)
- (match (package-names->package-inputs package-names)
- (()
- '())
- ((package-inputs ...)
- `(#:cargo-inputs (,'unquote (list ,@package-inputs))))))
-
-(define (maybe-cargo-development-inputs package-names)
- (match (package-names->package-inputs package-names)
- (()
- '())
- ((package-inputs ...)
- `(#:cargo-development-inputs (,'unquote (list ,@package-inputs))))))
-
-(define (maybe-arguments arguments)
- (match arguments
- (()
- '())
- ((args ...)
- `((arguments (,'quasiquote ,args))))))
-
(define (version->semver-prefix version)
"Return the version up to and including the first non-zero part"
(first
@@ -203,8 +183,14 @@ (define (format-inputs inputs)
(let* ((port (http-fetch (crate-uri name version)))
(guix-name (crate-name->package-name name))
- (cargo-inputs (format-inputs cargo-inputs))
- (cargo-development-inputs (format-inputs cargo-development-inputs))
+ (unwrap (match-lambda
+ ((lst) lst)
+ (() '())))
+ (cargo-inputs (maybe-packages-field '#:cargo-inputs
+ (format-inputs cargo-inputs)))
+ (cargo-development-inputs
+ (maybe-packages-field '#:cargo-development-inputs
+ (format-inputs cargo-development-inputs)))
(description (beautify-description description))
(pkg `(package
(name ,guix-name)
@@ -223,12 +209,12 @@ (define (format-inputs inputs)
`((properties '((crate-version-yanked? . #t))))
'())
(build-system cargo-build-system)
- ,@(maybe-arguments (append (if build?
- '()
- '(#:skip-build? #t))
- (maybe-cargo-inputs cargo-inputs)
- (maybe-cargo-development-inputs
- cargo-development-inputs)))
+ ,@(maybe-list-field 'arguments
+ (append (if build?
+ '()
+ '(#:skip-build? #t))
+ (unwrap cargo-inputs)
+ (unwrap cargo-development-inputs)))
(home-page ,home-page)
(synopsis ,(beautify-synopsis synopsis))
(description ,(if (string-prefix? "This" description)
@@ -240,11 +226,10 @@ (define (format-inputs inputs)
(#f #f)
((license) license)
(_ `(list ,@license)))))))
- (close-port port)
- (package->definition pkg
- (if yanked?
- (string-append version "-yanked")
- (version->semver-prefix version)))))
+ (close-port port)
+ (package->definition pkg (if yanked?
+ (string-append version "-yanked")
+ (version->semver-prefix version)))))
(define (string->license string)
(filter-map (lambda (license)
diff --git a/tests/crate.scm b/tests/crate.scm
index 63643c2728..95c93712a9 100644
--- a/tests/crate.scm
+++ b/tests/crate.scm
@@ -6,6 +6,7 @@
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; Copyright © 2023 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2023 David Elsing <david.elsing@posteo.net>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -498,10 +499,10 @@ (define have-guile-semver?
(? string? hash)))))
(build-system 'cargo-build-system)
(arguments
- ('quasiquote
- (#:skip-build? #t
+ (list
+ #:skip-build? #t
#:cargo-inputs
- ('unquote (list rust-leaf-alice-0.7)))))
+ (list rust-leaf-alice-0.7)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -590,7 +591,7 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:skip-build? #t)))
+ (list #:skip-build? #t))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -609,7 +610,7 @@ (define-public 'rust-leaf-alice-0.7
(base32
(? string? hash)))))
(build-system cargo-build-system)
- (arguments ('quasiquote (#:skip-build? #t)))
+ (arguments (list #:skip-build? #t))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -628,7 +629,7 @@ (define-public 'rust-leaf-bob-3
(base32
(? string? hash)))))
(build-system cargo-build-system)
- (arguments ('quasiquote (#:skip-build? #t)))
+ (arguments (list #:skip-build? #t))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -648,9 +649,9 @@ (define-public 'rust-intermediate-b-1
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:skip-build? #t
- #:cargo-inputs
- ('unquote (list rust-leaf-bob-3)))))
+ (list #:skip-build? #t
+ #:cargo-inputs
+ (list rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -670,11 +671,11 @@ (define-public 'rust-intermediate-a-1
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:skip-build? #t
- #:cargo-inputs
- ('unquote (list rust-intermediate-b-1
- rust-leaf-alice-0.7
- rust-leaf-bob-3)))))
+ (list #:skip-build? #t
+ #:cargo-inputs
+ (list rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -694,13 +695,13 @@ (define-public 'rust-root-1
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- ('unquote (list rust-intermediate-a-1
- rust-intermediate-b-1
- rust-leaf-alice-0.7
- rust-leaf-bob-3))
- #:cargo-development-inputs
- ('unquote (list rust-intermediate-c-1)))))
+ (list #:cargo-inputs
+ (list rust-intermediate-a-1
+ rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)
+ #:cargo-development-inputs
+ ((list rust-intermediate-c-1))))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -727,8 +728,8 @@ (define-public 'rust-root-1
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-development-inputs
- ('unquote (list rust-leaf-alice-0.7)))))
+ (list #:cargo-development-inputs
+ (list rust-leaf-alice-0.7)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -784,9 +785,8 @@ (define-public 'rust-intermediate-b-1
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-leaf-bob"
- ('unquote rust-leaf-bob-3))))))
+ (list #:cargo-inputs
+ (list rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -806,10 +806,10 @@ (define-public 'rust-intermediate-a-1
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- ('unquote (list rust-intermediate-b-1
- rust-leaf-alice-0.7
- rust-leaf-bob-3)))))
+ (list #:cargo-inputs
+ (list rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -829,13 +829,13 @@ (define-public 'rust-root-1
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- ('unquote (list rust-intermediate-a-1
- rust-intermediate-b-1
- rust-leaf-alice-0.7
- rust-leaf-bob-3))
- #:cargo-development-inputs
- ('unquote (list rust-intermediate-c-1)))))
+ (list #:cargo-inputs
+ (list rust-intermediate-a-1
+ rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)
+ #:cargo-development-inputs
+ (list rust-intermediate-c-1)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -945,11 +945,11 @@ (define rust-leaf-bob-3.0.2-yanked
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- ('unquote (list rust-leaf-bob-3))
- #:cargo-development-inputs
- ('unquote (list rust-leaf-bob-3.0.2-yanked
- rust-leaf-bob-4.0.0-yanked)))))
+ (list #:cargo-inputs
+ (list rust-leaf-bob-3)
+ #:cargo-development-inputs
+ (list rust-leaf-bob-3.0.2-yanked
+ rust-leaf-bob-4.0.0-yanked)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -1073,11 +1073,11 @@ (define-public 'rust-bar-1
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- ('unquote (list rust-leaf-bob-3))
- #:cargo-development-inputs
- ('unquote (list rust-leaf-bob-3.0.2-yanked
- rust-leaf-bob-4.0.0-yanked)))))
+ (list #:cargo-inputs
+ (list rust-leaf-bob-3)
+ #:cargo-development-inputs
+ (list rust-leaf-bob-3.0.2-yanked
+ rust-leaf-bob-4.0.0-yanked)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
--
2.45.2
H
H
Herman Rimm wrote on 4 Sep 22:32 +0200
[PATCH v2 05/12] import: utils: Add maybe-upstream-inputs.
(address . 70923@debbugs.gnu.org)
20240904203309.23715-5-herman@rimm.ee
* guix/import/utils.scm (maybe-upstream-inputs): Add procedure.

Change-Id: Ib8a80216d512c0373e55e4f27e1ef2a7c1fb854a
---
guix/import/utils.scm | 9 +++++++++
1 file changed, 9 insertions(+)

Toggle diff (36 lines)
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index 75bef1e9c7..152ae07a92 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -45,6 +45,7 @@ (define-module (guix import utils)
#:use-module (guix download)
#:use-module (guix sets)
#:use-module ((guix ui) #:select (fill-paragraph))
+ #:use-module (guix upstream)
#:use-module (gnu packages)
#:autoload (ice-9 control) (let/ec)
#:use-module (ice-9 match)
@@ -71,6 +72,7 @@ (define-module (guix import utils)
maybe-inputs
maybe-native-inputs
maybe-propagated-inputs
+ maybe-upstream-inputs
package->definition
spdx-string->license
@@ -460,6 +462,13 @@ (define* (maybe-propagated-inputs package-names #:optional (output #f))
"MAYBE-PACKAGES-FIELD for propagated inputs."
(maybe-packages-field 'propagated-inputs package-names output))
+(define* (maybe-upstream-inputs type upstream-inputs)
+ "Given a list of UPSTREAM-NAMES, tries to generate the TYPE field of a
+package definition."
+ (maybe-list-field type
+ (map (compose string->symbol upstream-input-downstream-name)
+ upstream-inputs)))
+
(define* (package->definition guix-package #:optional append-version?/string)
"If APPEND-VERSION?/STRING is #t, append the package's major+minor version.
If it is the symbol 'full, append the package's complete version. If
--
2.45.2
H
H
Herman Rimm wrote on 4 Sep 22:33 +0200
[PATCH v2 06/12] import: pypi: Use maybe-upstream-inputs.
(address . 70923@debbugs.gnu.org)
20240904203309.23715-6-herman@rimm.ee
* guix/import/pypi.scm (maybe-inputs): Delete procedure.
(make-pypi-sexp): Use maybe-upstream-inputs procedure.
---
guix/import/pypi.scm | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)

Toggle diff (48 lines)
diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm
index 7b9f54a200..a98fdfa604 100644
--- a/guix/import/pypi.scm
+++ b/guix/import/pypi.scm
@@ -14,6 +14,7 @@
;;; Copyright © 2022 Vivien Kraus <vivien@planete-kraus.eu>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -201,18 +202,6 @@ (define (wheel-url->extracted-directory wheel-url)
((name version _ ...)
(string-append name "-" version ".dist-info"))))
-(define (maybe-inputs package-inputs input-type)
- "Given a list of PACKAGE-INPUTS, tries to generate the 'inputs' field of a
-package definition. INPUT-TYPE, a symbol, is used to populate the name of
-the input field."
- (match package-inputs
- (()
- '())
- ((package-inputs ...)
- `((,input-type (list ,@(map (compose string->symbol
- upstream-input-downstream-name)
- package-inputs)))))))
-
(define %requirement-name-regexp
;; Regexp to match the requirement name in a requirement specification.
@@ -538,10 +527,10 @@ (define (maybe-upstream-name name)
bytevector->nix-base32-string)))))
,@(maybe-upstream-name name)
(build-system pyproject-build-system)
- ,@(maybe-inputs (upstream-source-propagated-inputs source)
- 'propagated-inputs)
- ,@(maybe-inputs (upstream-source-native-inputs source)
- 'native-inputs)
+ ,@(maybe-upstream-inputs 'propagated-inputs
+ (upstream-source-propagated-inputs source))
+ ,@(maybe-upstream-inputs 'native-inputs
+ (upstream-source-native-inputs source))
(home-page ,(project-info-home-page info))
(synopsis ,(project-info-summary info))
(description ,(and=> (non-empty-string-or-false
--
2.45.2
H
H
Herman Rimm wrote on 4 Sep 22:33 +0200
[PATCH v2 07/12] import: elpa: Use maybe-propagated-inputse.
(address . 70923@debbugs.gnu.org)
20240904203309.23715-7-herman@rimm.ee
* guix/import/elpa.scm (maybe-inputs): Delete procedure.
(elpa-package->sexp): Use maybe-propagated-inputs procedure.

Change-Id: I9b40e9d387311f5dbbb079938733bf945a1a6ee6
---
guix/import/elpa.scm | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)

Toggle diff (29 lines)
diff --git a/guix/import/elpa.scm b/guix/import/elpa.scm
index 46b6dc98a2..9ade189a8a 100644
--- a/guix/import/elpa.scm
+++ b/guix/import/elpa.scm
@@ -359,13 +359,6 @@ (define dependencies
(map (compose string->symbol elpa-name->package-name)
dependencies-names))
- (define (maybe-inputs input-type inputs)
- (match inputs
- (()
- '())
- ((inputs ...)
- (list (list input-type `(list ,@inputs))))))
-
(define melpa-source
(melpa-recipe->origin melpa-recipe))
@@ -386,7 +379,7 @@ (define melpa-source
(file-hash* tarball #:recursive? #false))
"failed to download package")))))))
(build-system emacs-build-system)
- ,@(maybe-inputs 'propagated-inputs dependencies)
+ ,@(maybe-propagated-inputs dependencies)
,@(if melpa-source
(melpa-recipe->maybe-arguments melpa-recipe)
'())
--
2.45.2
H
H
Herman Rimm wrote on 4 Sep 22:33 +0200
[PATCH v2 08/12] import: hackage: Use maybe-list-field.
(address . 70923@debbugs.gnu.org)
20240904203309.23715-8-herman@rimm.ee
* guix/import/hackage.scm (maybe-inputs, maybe-arguments): Delete
procedures.
(hackage-module->sexp): Use maybe-list-field and maybe-upstream-inputs
procedures.
* tests/hackage.scm: Fix whitespace and replace quasiquote with list.

Change-Id: I4fe39ff84c9f6a677f810d9e4fe751d762973757
---
guix/import/hackage.scm | 39 ++++++++++++---------------------------
tests/hackage.scm | 13 +++++++------
2 files changed, 19 insertions(+), 33 deletions(-)

Toggle diff (118 lines)
diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm
index 79a51d3300..bd3bed146e 100644
--- a/guix/import/hackage.scm
+++ b/guix/import/hackage.scm
@@ -9,6 +9,7 @@
;;; Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
;;; Copyright © 2023-2024 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -288,26 +289,6 @@ (define inputs
#:include-test-dependencies?
include-test-dependencies?))
- (define (maybe-inputs input-type inputs)
- (match inputs
- (()
- '())
- ((inputs ...)
- (list (list input-type
- `(list ,@(map (compose string->symbol
- upstream-input-downstream-name)
- inputs)))))))
-
- (define (maybe-arguments)
- (match (append (if (not include-test-dependencies?)
- '(#:tests? #f)
- '())
- (if (not (string-null? revision))
- `(#:cabal-revision (,revision ,cabal-hash))
- '()))
- (() '())
- (args `((arguments (,'quasiquote ,args))))))
-
(let ((tarball (with-store store
(download-to-store store source-url))))
(values
@@ -324,13 +305,17 @@ (define (maybe-arguments)
"failed to download tar archive")))))
(build-system haskell-build-system)
(properties '((upstream-name . ,name)))
- ,@(maybe-inputs 'inputs
- (filter (upstream-input-type-predicate 'regular)
- inputs))
- ,@(maybe-inputs 'native-inputs
- (filter (upstream-input-type-predicate 'native)
- inputs))
- ,@(maybe-arguments)
+ ,@(maybe-upstream-inputs 'inputs
+ (filter (upstream-input-type-predicate 'regular) inputs))
+ ,@(maybe-upstream-inputs 'native-inputs
+ (filter (upstream-input-type-predicate 'native) inputs))
+ ,@(maybe-list-field 'arguments
+ (append (if (not include-test-dependencies?)
+ '(#:tests? #f)
+ '())
+ (if (not (string-null? revision))
+ `(#:cabal-revision '(,revision ,cabal-hash))
+ '())))
(home-page ,(cabal-package-home-page cabal))
(synopsis ,(cabal-package-synopsis cabal))
(description ,(beautify-description (cabal-package-description cabal)))
diff --git a/tests/hackage.scm b/tests/hackage.scm
index 403f587c41..f6d91515e2 100644
--- a/tests/hackage.scm
+++ b/tests/hackage.scm
@@ -67,7 +67,7 @@ (define test-cabal-3
if impl(ghc>=7.2&&<7.6)
Build-depends: ghc-b
if impl(ghc == 7.8)
- Build-depends:
+ Build-depends:
HTTP >= 4000.2.5 && < 4000.3,
mtl >= 2.0 && < 3
")
@@ -86,7 +86,7 @@ (define test-cabal-4
if impl(ghc>=7.2&&<7.6)
Build-depends: ghc-b
if impl(ghc == 7.8)
- Build-depends:
+ Build-depends:
HTTP >= 4000.2.5 && < 4000.3,
mtl >= 2.0 && < 3
")
@@ -101,7 +101,7 @@ (define test-cabal-5
license: BSD3
library
if impl(ghc == 7.8)
- Build-depends:
+ Build-depends:
HTTP >= 4000.2.5 && < 4000.3,
if impl(ghc -any)
Build-depends: mtl >= 2.0 && < 3
@@ -126,7 +126,7 @@ (define test-cabal-6
if impl(ghc>=7.2&&<7.6)
Build-depends: ghc-b
if impl(ghc == 7.8)
- Build-depends:
+ Build-depends:
HTTP >= 4000.2.5 && < 4000.3,
mtl >= 2.0 && < 3
")
@@ -524,8 +524,9 @@ (define-package-matcher match-ghc-foo-revision
('properties '(quote ((upstream-name . "foo"))))
('inputs ('list 'ghc-http))
('arguments
- ('quasiquote
- ('#:cabal-revision
+ ('list
+ '#:cabal-revision
+ ('quote
("2" "0xxd88fb659f0krljidbvvmkh9ppjnx83j0nqzx8whcg4n5qbyng"))))
('home-page "http://test.org")
('synopsis (? string?))
--
2.45.2
H
H
Herman Rimm wrote on 4 Sep 22:33 +0200
[PATCH v2 09/12] import: cran: Refactor format-inputs and use maybe-list-field.
(address . 70923@debbugs.gnu.org)
20240904203309.23715-9-herman@rimm.ee
* guix/import/cran.scm (format-inputs): Split and move procedure ...
(maybe-inputs): ... to here, and use maybe-list-field procedure.

Change-Id: I5148afcebdac1f7fa0f8cce9e82e8cebb56c36c8
---
guix/import/cran.scm | 36 ++++++++++++++++--------------------
1 file changed, 16 insertions(+), 20 deletions(-)

Toggle diff (63 lines)
diff --git a/guix/import/cran.scm b/guix/import/cran.scm
index 6ae00cae96..bdac059053 100644
--- a/guix/import/cran.scm
+++ b/guix/import/cran.scm
@@ -6,6 +6,7 @@
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -85,21 +86,6 @@ (define-module (guix import cran)
(define %input-style
(make-parameter 'variable)) ; or 'specification
-(define (format-inputs inputs)
- "Generate a sorted list of package inputs from a list of upstream inputs."
- (map (lambda (input)
- (case (%input-style)
- ((specification)
- `(specification->package ,(upstream-input-downstream-name input)))
- (else
- ((compose string->symbol
- upstream-input-downstream-name)
- input))))
- (sort inputs
- (lambda (a b)
- (string-ci<? (upstream-input-name a)
- (upstream-input-name b))))))
-
(define (string->licenses license-string license-prefix)
(let ((licenses
(map string-trim-both
@@ -188,11 +174,21 @@ (define (description->alist description)
(define* (maybe-inputs package-inputs #:optional (input-type 'inputs))
"Given a list of PACKAGE-INPUTS, tries to generate the TYPE field of a
package definition."
- (match package-inputs
- (()
- '())
- ((package-inputs ...)
- `((,input-type (list ,@(format-inputs package-inputs)))))))
+ (define (format-input input)
+ (case (%input-style)
+ ((specification)
+ `(specification->package ,(upstream-input-downstream-name input)))
+ (else
+ ((compose string->symbol
+ upstream-input-downstream-name)
+ input))))
+
+ (define (upstream-input-name<? i1 i2)
+ (string-ci<? (upstream-input-name i1)
+ (upstream-input-name i2)))
+
+ (maybe-list-field input-type
+ (map format-input (sort package-inputs upstream-input-name<?))))
(define %cran-url "https://cloud.r-project.org/web/packages/")
(define %cran-canonical-url "https://cran.r-project.org/package=")
--
2.45.2
H
H
Herman Rimm wrote on 4 Sep 22:33 +0200
[PATCH v2 10/12] import: cpan: Use maybe-upstream-inputs.
(address . 70923@debbugs.gnu.org)
20240904203309.23715-10-herman@rimm.ee
* guix/import/cpan.scm (maybe-inputs): Delete procedure.
(cpan-module->sexp): Use maybe-upstream-inputs procedure.

Change-Id: I4fa99da62d81f02c2998ad96f5ea81e27df071cd
---
guix/import/cpan.scm | 23 +++++++----------------
1 file changed, 7 insertions(+), 16 deletions(-)

Toggle diff (57 lines)
diff --git a/guix/import/cpan.scm b/guix/import/cpan.scm
index b87736eef6..611ea63eba 100644
--- a/guix/import/cpan.scm
+++ b/guix/import/cpan.scm
@@ -5,6 +5,7 @@
;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2020, 2021, 2023 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -37,7 +38,8 @@ (define-module (guix import cpan)
#:use-module (guix utils)
#:use-module (guix base32)
#:use-module ((guix download) #:select (download-to-store url-fetch))
- #:use-module ((guix import utils) #:select (factorize-uri))
+ #:use-module ((guix import utils) #:select (factorize-uri
+ maybe-upstream-inputs))
#:use-module (guix import json)
#:use-module (guix packages)
#:use-module (guix upstream)
@@ -275,15 +277,6 @@ (define name
(define version (cpan-release-version release))
(define source-url (cpan-source-url release))
- (define (maybe-inputs input-type inputs)
- (match inputs
- (()
- '())
- ((inputs ...)
- `((,input-type (list ,@(map (compose string->symbol
- upstream-input-downstream-name)
- inputs)))))))
-
(let ((tarball (with-store store
(download-to-store store source-url)))
(inputs (cpan-module-inputs release)))
@@ -297,12 +290,10 @@ (define (maybe-inputs input-type inputs)
(base32
,(bytevector->nix-base32-string (file-sha256 tarball))))))
(build-system perl-build-system)
- ,@(maybe-inputs 'native-inputs
- (filter (upstream-input-type-predicate 'native)
- inputs))
- ,@(maybe-inputs 'propagated-inputs
- (filter (upstream-input-type-predicate 'propagated)
- inputs))
+ ,@(maybe-upstream-inputs 'native-inputs
+ (filter (upstream-input-type-predicate 'native) inputs))
+ ,@(maybe-upstream-inputs 'propagated-inputs
+ (filter (upstream-input-type-predicate 'propagated) inputs))
(home-page ,(cpan-home name))
(synopsis ,(cpan-release-abstract release))
(description fill-in-yourself!)
--
2.45.2
H
H
Herman Rimm wrote on 4 Sep 22:33 +0200
[PATCH v2 11/12] import: egg: Use maybe-*inputs procedures.
(address . 70923@debbugs.gnu.org)
20240904203309.23715-11-herman@rimm.ee
* guix/import/egg.scm (maybe-inputs): Delete procedure.
(egg-parse-dependency): Simplify procedure to return strings.
(egg->guix-package): Use maybe-*inputs procedures.

Change-Id: Ib0a3f5b6f02912c847defd02ba7675d80005279b
---
guix/import/egg.scm | 39 +++++++++++----------------------------
1 file changed, 11 insertions(+), 28 deletions(-)

Toggle diff (81 lines)
diff --git a/guix/import/egg.scm b/guix/import/egg.scm
index e3bc158475..97d09a7c9d 100644
--- a/guix/import/egg.scm
+++ b/guix/import/egg.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2021 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -229,23 +230,14 @@ (define (prettify-system-dependency name)
(else char)))
(maybe-symbol->string name)))
- (define* (egg-parse-dependency name #:key (system? #f))
- (define extract-name
- (match-lambda
- ((name version) name)
- (name name)))
-
- (define (prettify-name name)
+ (define* (egg-parse-dependency dependency #:key (system? #f))
+ (let ((name (match dependency
+ ((name version) name)
+ (name name))))
(if system?
(prettify-system-dependency name)
- (maybe-symbol->string name)))
-
- (let ((name (prettify-name (extract-name name))))
- ;; Dependencies are sometimes specified as symbols and sometimes
- ;; as strings
- (string->symbol (string-append
- (if system? "" package-name-prefix)
- name))))
+ (string-append package-name-prefix
+ (maybe-symbol->string name)))))
(define egg-propagated-inputs
(let ((dependencies (assoc-ref egg-content 'dependencies)))
@@ -277,15 +269,6 @@ (define egg-native-inputs
test+build-dependencies))
(() '()))))
- ;; Copied from (guix import hackage).
- (define (maybe-inputs input-type inputs)
- (match inputs
- (()
- '())
- ((inputs ...)
- (list (list input-type
- `(list ,@inputs))))))
-
(values
`(package
(name ,(egg-name->guix-name name))
@@ -303,16 +286,16 @@ (define (maybe-inputs input-type inputs)
"failed to download tar archive"))))))
(build-system chicken-build-system)
(arguments ,(list 'quasiquote (list #:egg-name name)))
- ,@(maybe-inputs 'native-inputs egg-native-inputs)
- ,@(maybe-inputs 'inputs egg-inputs)
- ,@(maybe-inputs 'propagated-inputs egg-propagated-inputs)
+ ,@(maybe-native-inputs egg-native-inputs)
+ ,@(maybe-inputs egg-inputs)
+ ,@(maybe-propagated-inputs egg-propagated-inputs)
(home-page ,egg-home-page)
(synopsis ,egg-synopsis)
(description #f)
(license ,egg-licenses))
(filter (lambda (name)
(not (member name '("srfi-4"))))
- (map (compose guix-name->egg-name symbol->string)
+ (map guix-name->egg-name
(append egg-propagated-inputs
egg-native-inputs)))))))
--
2.45.2
H
H
Herman Rimm wrote on 4 Sep 22:33 +0200
[PATCH v2 12/12] import: hexpm: Use maybe-inputs.
(address . 70923@debbugs.gnu.org)
20240904203309.23715-12-herman@rimm.ee
* guix/import/hexpm.scm (maybe-inputs): Delete procedure.
(dependencies->package-names): Adjust description and return strings.
(make-hexpm-sexp): Use maybe-inputs procedure.

Change-Id: Ie7a8a630a3a9d4859453d49fdee42aa560e27f17
---
guix/import/hexpm.scm | 29 +++++++++--------------------
1 file changed, 9 insertions(+), 20 deletions(-)

Toggle diff (57 lines)
diff --git a/guix/import/hexpm.scm b/guix/import/hexpm.scm
index 71a54ba973..aa857facbc 100644
--- a/guix/import/hexpm.scm
+++ b/guix/import/hexpm.scm
@@ -5,6 +5,7 @@
;;; Copyright © 2019 Martin Becze <mjbecze@riseup.net>
;;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2020-2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -153,26 +154,14 @@ (define (lookup-hexpm-release version*)
;;; Converting hex.pm packages to Guix packages.
;;;
-(define (maybe-inputs package-inputs input-type)
- "Given a list of PACKAGE-INPUTS, tries to generate the 'inputs' field of a
-package definition. INPUT-TYPE, a symbol, is used to populate the name of
-the input field."
- (match package-inputs
- (()
- '())
- ((package-inputs ...)
- `((,input-type (list ,@package-inputs))))))
-
(define (dependencies->package-names names)
- "Given a list of hexpm package NAMES, returns a list of guix package names
-as symbols."
- ;; TODO: Base name on language of dependency.
- ;; The language used for implementing the dependency is not know without
- ;; recursing the dependencies. So for now assume more packages are based on
- ;; Erlang and prefix all dependencies with "erlang-" (the default).
- (map string->symbol
- (map hexpm-name->package-name
- (sort names string-ci<?))))
+ "Given NAMES, a list of hexpm dependencies, return a list of guix
+package names."
+ ;; TODO: Base name on the programming language of the dependency.
+ ;; The language used for implementing the dependency can only be known
+ ;; by traversing the dependencies. So for now assume packages are
+ ;; based on Erlang, and prefix dependencies with "erlang-" by default.
+ (map hexpm-name->package-name (sort names string-ci<?)))
(define* (make-hexpm-sexp #:key name version tarball-url
home-page synopsis description license
@@ -194,7 +183,7 @@ (define* (make-hexpm-sexp #:key name version tarball-url
(uri (hexpm-uri ,name version))
(sha256 (base32 ,(guix-hash-url temp)))))
(build-system ,build-system)
- ,@(maybe-inputs (dependencies->package-names dependencies) 'inputs)
+ ,@(maybe-inputs (dependencies->package-names dependencies))
(synopsis ,synopsis)
(description ,(beautify-description description))
(home-page ,(match home-page
--
2.45.2
H
H
Herman Rimm wrote on 24 Sep 22:13 +0200
[PATCH v3 00/11] Add (guix import utils) procedures.
(address . 70923@debbugs.gnu.org)
cover.1727207512.git.herman@rimm.ee
Hello,

The fix for #72939 reverts the commit for which I had provided a
modified version in the first revision of this series. It does not
introduce the bug in #72939. Also, revision v2 of this series would
have fixed that bug. I assume that unfortunately, once again, I had not
CC'ed any maintainers the second revision. Now, I have created a third
revision, two patches fewer than the first. One commit had adjusted
tests/go.scm to the new-style inputs, which a remaining commit from the
same series as the reverted commit does instead. The other commit fixed
tests/elm.scm, but now 7979001c58fcadd98bae09781c495f0a462d6e04 does
that instead. Hopefully this revision does get reviewed, or (re)starts
some discussion.

Cheers,
Herman

Herman Rimm (9):
build-system: cargo: Accept unlabeled #:cargo-inputs.
import: utils: Add 'maybe-upstream-inputs' procedure.
import: pypi: Use 'maybe-list-field' procedure.
import: elpa: Use maybe-propagated-inputs procedure.
import: hackage: Use 'maybe-list-field' procedure.
import: cran: Use 'maybe-list-field' procedure.
import: cpan: Use 'maybe-upstream-inputs' procedure.
import: egg: Use maybe-*inputs procedures.
import: hexpm: Use (guix import utils) 'maybe-inputs' procedure.

Sarah Morgensen (2):
import: utils: Emit new-style package inputs.
import: crate: Emit new-style package inputs.

guix/build-system/cargo.scm | 12 ++--
guix/import/cpan.scm | 23 +++----
guix/import/cran.scm | 36 +++++------
guix/import/crate.scm | 51 ++++++----------
guix/import/egg.scm | 39 ++++--------
guix/import/elpa.scm | 9 +--
guix/import/hackage.scm | 39 ++++--------
guix/import/hexpm.scm | 29 +++------
guix/import/pypi.scm | 21 ++-----
guix/import/utils.scm | 61 +++++++++++-------
tests/crate.scm | 119 +++++++++++++++---------------------
tests/hackage.scm | 13 ++--
12 files changed, 180 insertions(+), 272 deletions(-)


base-commit: 3ac69c1a757430d6dfdd37eb948ba1d6967967cc
--
2.45.2
H
H
Herman Rimm wrote on 24 Sep 22:13 +0200
[PATCH v3 01/11] build-system: cargo: Accept unlabeled #:cargo-inputs.
(address . 70923@debbugs.gnu.org)
368720732ff9491a4ab81657c4691f79ee2c9d5b.1727207512.git.herman@rimm.ee
* guix/build-system/cargo.scm (crate-closure): Match unlabeled inputs.

Change-Id: Iae421281fa08d09ddd1e5d2da2864f0093d97cd1
---
guix/build-system/cargo.scm | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

Toggle diff (42 lines)
diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 658a2e525e..2e3061c0e8 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -6,6 +6,7 @@
;;; Copyright © 2019 Ivan Petkov <ivanppetkov@gmail.com>
;;; Copyright © 2020 Jakub K?dzio?ka <kuba@kadziolka.net>
;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -234,11 +235,14 @@ (define (crate-closure inputs)
(if (null? propagated)
(reverse result)
(loop (reverse (concatenate propagated)) result '() #f seen)))
- (((and input (label (? package? package))) rest ...)
+ ;; Match inputs with labels for backward compatibility.
+ (((or (_ (? package? package))
+ (? package? package))
+ rest ...)
(if (and (not first?) (seen? seen package))
(loop rest result propagated first? seen)
(loop rest
- (cons input result)
+ (cons package result)
(cons (package-cargo-inputs package)
propagated)
first?
@@ -296,8 +300,8 @@ (define (expand-crate-sources cargo-inputs cargo-development-inputs)
something that can always be extended or reworked in the future)."
(filter-map
(match-lambda
- ((label (? package? p))
- (list label (package-source p)))
+ ((? package? p)
+ (list (package-name p) (package-source p)))
((label input)
(list label input)))
(crate-closure (append cargo-inputs cargo-development-inputs))))
--
2.45.2
H
H
Herman Rimm wrote on 24 Sep 22:13 +0200
[PATCH v3 03/11] import: crate: Emit new-style package inputs.
(address . 70923@debbugs.gnu.org)(name . Sarah Morgensen)(address . iskarian@mgsn.dev)
a8da5c9ad4c8dea79bd332ae25f3d042204a74a0.1727207512.git.herman@rimm.ee
From: Sarah Morgensen <iskarian@mgsn.dev>

* guix/import/crate.scm (maybe-cargo-inputs,
maybe-cargo-development-inputs, maybe-arguments): Delete procedures.
(make-crate-sexp): Add 'unwrap' procedure, use with maybe-packages-field
and fix indentation.
* tests/crate.scm: Adjust accordingly.

Change-Id: Ie8debd2553a338c3c623162b843e0a9827314074
---
guix/import/crate.scm | 51 ++++++------------
tests/crate.scm | 119 +++++++++++++++++-------------------------
2 files changed, 65 insertions(+), 105 deletions(-)

Toggle diff (314 lines)
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 84c178ea3e..5110e6124f 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -7,6 +7,7 @@
;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2023, 2024 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2023, 2024 David Elsing <david.elsing@posteo.net>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -158,27 +159,6 @@ (define* (package-names->package-inputs names #:optional (output #f))
(input (make-input input #f)))
names))
-(define (maybe-cargo-inputs package-names)
- (match (package-names->package-inputs package-names)
- (()
- '())
- ((package-inputs ...)
- `(#:cargo-inputs ,package-inputs))))
-
-(define (maybe-cargo-development-inputs package-names)
- (match (package-names->package-inputs package-names)
- (()
- '())
- ((package-inputs ...)
- `(#:cargo-development-inputs ,package-inputs))))
-
-(define (maybe-arguments arguments)
- (match arguments
- (()
- '())
- ((args ...)
- `((arguments (,'quasiquote ,args))))))
-
(define (version->semver-prefix version)
"Return the version up to and including the first non-zero part"
(first
@@ -202,8 +182,14 @@ (define* (make-crate-sexp #:key name version cargo-inputs cargo-development-inpu
(let* ((port (http-fetch (crate-uri name version)))
(guix-name (crate-name->package-name name))
- (cargo-inputs (format-inputs cargo-inputs))
- (cargo-development-inputs (format-inputs cargo-development-inputs))
+ (unwrap (match-lambda
+ ((lst) lst)
+ (() '())))
+ (cargo-inputs (maybe-packages-field '#:cargo-inputs
+ (format-inputs cargo-inputs)))
+ (cargo-development-inputs
+ (maybe-packages-field '#:cargo-development-inputs
+ (format-inputs cargo-development-inputs)))
(description (beautify-description description))
(pkg `(package
(name ,guix-name)
@@ -222,12 +208,10 @@ (define* (make-crate-sexp #:key name version cargo-inputs cargo-development-inpu
`((properties '((crate-version-yanked? . #t))))
'())
(build-system cargo-build-system)
- ,@(maybe-arguments (append (if build?
- '()
- '(#:skip-build? #t))
- (maybe-cargo-inputs cargo-inputs)
- (maybe-cargo-development-inputs
- cargo-development-inputs)))
+ ,@(maybe-list-field 'arguments
+ (append (if build? '() '(#:skip-build? #t))
+ (unwrap cargo-inputs)
+ (unwrap cargo-development-inputs)))
(home-page ,home-page)
(synopsis ,(beautify-synopsis synopsis))
(description ,(if (string-prefix? "This" description)
@@ -239,11 +223,10 @@ (define* (make-crate-sexp #:key name version cargo-inputs cargo-development-inpu
(#f #f)
((license) license)
(_ `(list ,@license)))))))
- (close-port port)
- (package->definition pkg
- (if yanked?
- (string-append version "-yanked")
- (version->semver-prefix version)))))
+ (close-port port)
+ (package->definition pkg (if yanked?
+ (string-append version "-yanked")
+ (version->semver-prefix version)))))
(define (string->license string)
(filter-map (lambda (license)
diff --git a/tests/crate.scm b/tests/crate.scm
index 5b4ad08c3c..8e3da2e72c 100644
--- a/tests/crate.scm
+++ b/tests/crate.scm
@@ -5,6 +5,8 @@
;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
;;; Copyright © 2023 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2023 David Elsing <david.elsing@posteo.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -497,10 +499,10 @@ (define have-guile-semver?
(? string? hash)))))
(build-system 'cargo-build-system)
(arguments
- ('quasiquote
- (#:skip-build? #t
+ (list
+ #:skip-build? #t
#:cargo-inputs
- (("rust-leaf-alice" ('unquote 'rust-leaf-alice-0.7))))))
+ (list rust-leaf-alice-0.7)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -589,7 +591,7 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:skip-build? #t)))
+ (list #:skip-build? #t))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -608,7 +610,7 @@ (define have-guile-semver?
(base32
(? string? hash)))))
(build-system cargo-build-system)
- (arguments ('quasiquote (#:skip-build? #t)))
+ (arguments (list #:skip-build? #t))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -627,7 +629,7 @@ (define have-guile-semver?
(base32
(? string? hash)))))
(build-system cargo-build-system)
- (arguments ('quasiquote (#:skip-build? #t)))
+ (arguments (list #:skip-build? #t))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -647,10 +649,9 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:skip-build? #t
- #:cargo-inputs
- (("rust-leaf-bob"
- ('unquote rust-leaf-bob-3))))))
+ (list #:skip-build? #t
+ #:cargo-inputs
+ (list rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -670,14 +671,11 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:skip-build? #t
- #:cargo-inputs
- (("rust-intermediate-b"
- ('unquote rust-intermediate-b-1))
- ("rust-leaf-alice"
- ('unquote 'rust-leaf-alice-0.7))
- ("rust-leaf-bob"
- ('unquote rust-leaf-bob-3))))))
+ (list #:skip-build? #t
+ #:cargo-inputs
+ (list rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -697,18 +695,13 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-intermediate-a"
- ('unquote rust-intermediate-a-1))
- ("rust-intermediate-b"
- ('unquote rust-intermediate-b-1))
- ("rust-leaf-alice"
- ('unquote 'rust-leaf-alice-0.7))
- ("rust-leaf-bob"
- ('unquote rust-leaf-bob-3)))
- #:cargo-development-inputs
- (("rust-intermediate-c"
- ('unquote rust-intermediate-c-1))))))
+ (list #:cargo-inputs
+ (list rust-intermediate-a-1
+ rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)
+ #:cargo-development-inputs
+ ((list rust-intermediate-c-1))))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -735,9 +728,8 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-development-inputs
- (("rust-leaf-alice"
- ('unquote rust-leaf-alice-0.7))))))
+ (list #:cargo-development-inputs
+ (list rust-leaf-alice-0.7)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -793,9 +785,8 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-leaf-bob"
- ('unquote rust-leaf-bob-3))))))
+ (list #:cargo-inputs
+ (list rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -815,13 +806,10 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-intermediate-b"
- ('unquote rust-intermediate-b-1))
- ("rust-leaf-alice"
- ('unquote 'rust-leaf-alice-0.7))
- ("rust-leaf-bob"
- ('unquote rust-leaf-bob-3))))))
+ (list #:cargo-inputs
+ (list rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -841,18 +829,13 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-intermediate-a"
- ('unquote rust-intermediate-a-1))
- ("rust-intermediate-b"
- ('unquote rust-intermediate-b-1))
- ("rust-leaf-alice"
- ('unquote 'rust-leaf-alice-0.7))
- ("rust-leaf-bob"
- ('unquote rust-leaf-bob-3)))
- #:cargo-development-inputs
- (("rust-intermediate-c"
- ('unquote rust-intermediate-c-1))))))
+ (list #:cargo-inputs
+ (list rust-intermediate-a-1
+ rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)
+ #:cargo-development-inputs
+ (list rust-intermediate-c-1)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -962,14 +945,11 @@ (define rust-leaf-bob-3.0.2-yanked
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-3)))
- #:cargo-development-inputs
- (("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-3.0.2-yanked))
- ("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-4.0.0-yanked))))))
+ (list #:cargo-inputs
+ (list rust-leaf-bob-3)
+ #:cargo-development-inputs
+ (list rust-leaf-bob-3.0.2-yanked
+ rust-leaf-bob-4.0.0-yanked)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -1093,14 +1073,11 @@ (define rust-leaf-bob-3.0.2-yanked
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-3)))
- #:cargo-development-inputs
- (("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-3.0.2-yanked))
- ("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-4.0.0-yanked))))))
+ (list #:cargo-inputs
+ (list rust-leaf-bob-3)
+ #:cargo-development-inputs
+ (list rust-leaf-bob-3.0.2-yanked
+ rust-leaf-bob-4.0.0-yanked)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
--
2.45.2
H
H
Herman Rimm wrote on 24 Sep 22:13 +0200
[PATCH v3 02/11] import: utils: Emit new-style package inputs.
(address . 70923@debbugs.gnu.org)(name . Sarah Morgensen)(address . iskarian@mgsn.dev)
3776de27f3b8917f8d3272ba167ebfe5ce707a5c.1727207512.git.herman@rimm.ee
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(-)

Toggle diff (90 lines)
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index b7756fcc40..88a1db4a88 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
@@ -418,39 +421,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
H
H
Herman Rimm wrote on 24 Sep 22:13 +0200
[PATCH v3 04/11] import: utils: Add 'maybe-upstream-inputs' procedure.
(address . 70923@debbugs.gnu.org)
3e09ff0327c2cb53598bce0f94bd39b9cb7937f7.1727207512.git.herman@rimm.ee
* guix/import/utils.scm (maybe-upstream-inputs): Add procedure.

Change-Id: Ib8a80216d512c0373e55e4f27e1ef2a7c1fb854a
---
guix/import/utils.scm | 9 +++++++++
1 file changed, 9 insertions(+)

Toggle diff (36 lines)
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index 88a1db4a88..6d62b64433 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -45,6 +45,7 @@ (define-module (guix import utils)
#:use-module (guix download)
#:use-module (guix sets)
#:use-module ((guix ui) #:select (fill-paragraph))
+ #:use-module (guix upstream)
#:use-module (gnu packages)
#:autoload (ice-9 control) (let/ec)
#:use-module (ice-9 match)
@@ -71,6 +72,7 @@ (define-module (guix import utils)
maybe-inputs
maybe-native-inputs
maybe-propagated-inputs
+ maybe-upstream-inputs
package->definition
spdx-string->license
@@ -460,6 +462,13 @@ (define* (maybe-propagated-inputs package-names #:optional (output #f))
"MAYBE-PACKAGES-FIELD for propagated inputs."
(maybe-packages-field 'propagated-inputs package-names output))
+(define* (maybe-upstream-inputs type upstream-inputs)
+ "Given a list of UPSTREAM-NAMES, tries to generate the TYPE field of a
+package definition."
+ (maybe-list-field type
+ (map (compose string->symbol upstream-input-downstream-name)
+ upstream-inputs)))
+
(define* (package->definition guix-package #:optional append-version?/string)
"If APPEND-VERSION?/STRING is #t, append the package's major+minor version.
If it is the symbol 'full, append the package's complete version. If
--
2.45.2
H
H
Herman Rimm wrote on 24 Sep 22:13 +0200
[PATCH v3 05/11] import: pypi: Use 'maybe-list-field' procedure.
(address . 70923@debbugs.gnu.org)
386fffa725214f9b75995caf3c4f9780f2ee2340.1727207512.git.herman@rimm.ee
* guix/import/pypi.scm (maybe-inputs): Delete procedure.
(make-pypi-sexp): Use 'maybe-list-field' and 'maybe-upstream-inputs'
procedures.
---
guix/import/pypi.scm | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)

Toggle diff (48 lines)
diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm
index 7b9f54a200..a98fdfa604 100644
--- a/guix/import/pypi.scm
+++ b/guix/import/pypi.scm
@@ -14,6 +14,7 @@
;;; Copyright © 2022 Vivien Kraus <vivien@planete-kraus.eu>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -201,18 +202,6 @@ (define (wheel-url->extracted-directory wheel-url)
((name version _ ...)
(string-append name "-" version ".dist-info"))))
-(define (maybe-inputs package-inputs input-type)
- "Given a list of PACKAGE-INPUTS, tries to generate the 'inputs' field of a
-package definition. INPUT-TYPE, a symbol, is used to populate the name of
-the input field."
- (match package-inputs
- (()
- '())
- ((package-inputs ...)
- `((,input-type (list ,@(map (compose string->symbol
- upstream-input-downstream-name)
- package-inputs)))))))
-
(define %requirement-name-regexp
;; Regexp to match the requirement name in a requirement specification.
@@ -538,10 +527,10 @@ (define* (make-pypi-sexp pypi-package
bytevector->nix-base32-string)))))
,@(maybe-upstream-name name)
(build-system pyproject-build-system)
- ,@(maybe-inputs (upstream-source-propagated-inputs source)
- 'propagated-inputs)
- ,@(maybe-inputs (upstream-source-native-inputs source)
- 'native-inputs)
+ ,@(maybe-upstream-inputs 'propagated-inputs
+ (upstream-source-propagated-inputs source))
+ ,@(maybe-upstream-inputs 'native-inputs
+ (upstream-source-native-inputs source))
(home-page ,(project-info-home-page info))
(synopsis ,(project-info-summary info))
(description ,(and=> (non-empty-string-or-false
--
2.45.2
H
H
Herman Rimm wrote on 24 Sep 22:13 +0200
[PATCH v3 06/11] import: elpa: Use maybe-propagated-inputs procedure.
(address . 70923@debbugs.gnu.org)
251731aef2570f6caa96044b760a77dd97a1f336.1727207512.git.herman@rimm.ee
* guix/import/elpa.scm (maybe-inputs): Delete procedure.
(elpa-package->sexp): Use maybe-propagated-inputs procedure.

Change-Id: I9b40e9d387311f5dbbb079938733bf945a1a6ee6
---
guix/import/elpa.scm | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)

Toggle diff (29 lines)
diff --git a/guix/import/elpa.scm b/guix/import/elpa.scm
index 46b6dc98a2..9ade189a8a 100644
--- a/guix/import/elpa.scm
+++ b/guix/import/elpa.scm
@@ -359,13 +359,6 @@ (define* (elpa-package->sexp pkg #:optional license repo)
(map (compose string->symbol elpa-name->package-name)
dependencies-names))
- (define (maybe-inputs input-type inputs)
- (match inputs
- (()
- '())
- ((inputs ...)
- (list (list input-type `(list ,@inputs))))))
-
(define melpa-source
(melpa-recipe->origin melpa-recipe))
@@ -386,7 +379,7 @@ (define* (elpa-package->sexp pkg #:optional license repo)
(file-hash* tarball #:recursive? #false))
"failed to download package")))))))
(build-system emacs-build-system)
- ,@(maybe-inputs 'propagated-inputs dependencies)
+ ,@(maybe-propagated-inputs dependencies)
,@(if melpa-source
(melpa-recipe->maybe-arguments melpa-recipe)
'())
--
2.45.2
H
H
Herman Rimm wrote on 24 Sep 22:13 +0200
[PATCH v3 08/11] import: cran: Use 'maybe-list-field' procedure.
(address . 70923@debbugs.gnu.org)
c07cec66e016bc360978425f9aeb0974077e3140.1727207512.git.herman@rimm.ee
* guix/import/cran.scm (format-inputs): Delete procedure.
(maybe-inputs): Use 'maybe-list-field' procedure.

Change-Id: I5148afcebdac1f7fa0f8cce9e82e8cebb56c36c8
---
guix/import/cran.scm | 36 ++++++++++++++++--------------------
1 file changed, 16 insertions(+), 20 deletions(-)

Toggle diff (63 lines)
diff --git a/guix/import/cran.scm b/guix/import/cran.scm
index 6ae00cae96..bdac059053 100644
--- a/guix/import/cran.scm
+++ b/guix/import/cran.scm
@@ -6,6 +6,7 @@
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -85,21 +86,6 @@ (define-module (guix import cran)
(define %input-style
(make-parameter 'variable)) ; or 'specification
-(define (format-inputs inputs)
- "Generate a sorted list of package inputs from a list of upstream inputs."
- (map (lambda (input)
- (case (%input-style)
- ((specification)
- `(specification->package ,(upstream-input-downstream-name input)))
- (else
- ((compose string->symbol
- upstream-input-downstream-name)
- input))))
- (sort inputs
- (lambda (a b)
- (string-ci<? (upstream-input-name a)
- (upstream-input-name b))))))
-
(define (string->licenses license-string license-prefix)
(let ((licenses
(map string-trim-both
@@ -188,11 +174,21 @@ (define (description->alist description)
(define* (maybe-inputs package-inputs #:optional (input-type 'inputs))
"Given a list of PACKAGE-INPUTS, tries to generate the TYPE field of a
package definition."
- (match package-inputs
- (()
- '())
- ((package-inputs ...)
- `((,input-type (list ,@(format-inputs package-inputs)))))))
+ (define (format-input input)
+ (case (%input-style)
+ ((specification)
+ `(specification->package ,(upstream-input-downstream-name input)))
+ (else
+ ((compose string->symbol
+ upstream-input-downstream-name)
+ input))))
+
+ (define (upstream-input-name<? i1 i2)
+ (string-ci<? (upstream-input-name i1)
+ (upstream-input-name i2)))
+
+ (maybe-list-field input-type
+ (map format-input (sort package-inputs upstream-input-name<?))))
(define %cran-url "https://cloud.r-project.org/web/packages/")
(define %cran-canonical-url "https://cran.r-project.org/package=")
--
2.45.2
H
H
Herman Rimm wrote on 24 Sep 22:13 +0200
[PATCH v3 07/11] import: hackage: Use 'maybe-list-field' procedure.
(address . 70923@debbugs.gnu.org)
1bc3fa4669d55efc9bf5c7fdf97efc39b03fab23.1727207512.git.herman@rimm.ee
* guix/import/hackage.scm (maybe-inputs, maybe-arguments): Delete
procedures.
(hackage-module->sexp): Use 'maybe-list-field' and
'maybe-upstream-inputs' procedures.
* tests/hackage.scm: Fix whitespace and replace 'quasiquote' with
'list'.

Change-Id: I4fe39ff84c9f6a677f810d9e4fe751d762973757
---
guix/import/hackage.scm | 39 ++++++++++++---------------------------
tests/hackage.scm | 13 +++++++------
2 files changed, 19 insertions(+), 33 deletions(-)

Toggle diff (118 lines)
diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm
index 79a51d3300..bd3bed146e 100644
--- a/guix/import/hackage.scm
+++ b/guix/import/hackage.scm
@@ -9,6 +9,7 @@
;;; Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
;;; Copyright © 2023-2024 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -288,26 +289,6 @@ (define* (hackage-module->sexp cabal cabal-hash
#:include-test-dependencies?
include-test-dependencies?))
- (define (maybe-inputs input-type inputs)
- (match inputs
- (()
- '())
- ((inputs ...)
- (list (list input-type
- `(list ,@(map (compose string->symbol
- upstream-input-downstream-name)
- inputs)))))))
-
- (define (maybe-arguments)
- (match (append (if (not include-test-dependencies?)
- '(#:tests? #f)
- '())
- (if (not (string-null? revision))
- `(#:cabal-revision (,revision ,cabal-hash))
- '()))
- (() '())
- (args `((arguments (,'quasiquote ,args))))))
-
(let ((tarball (with-store store
(download-to-store store source-url))))
(values
@@ -324,13 +305,17 @@ (define* (hackage-module->sexp cabal cabal-hash
"failed to download tar archive")))))
(build-system haskell-build-system)
(properties '((upstream-name . ,name)))
- ,@(maybe-inputs 'inputs
- (filter (upstream-input-type-predicate 'regular)
- inputs))
- ,@(maybe-inputs 'native-inputs
- (filter (upstream-input-type-predicate 'native)
- inputs))
- ,@(maybe-arguments)
+ ,@(maybe-upstream-inputs 'inputs
+ (filter (upstream-input-type-predicate 'regular) inputs))
+ ,@(maybe-upstream-inputs 'native-inputs
+ (filter (upstream-input-type-predicate 'native) inputs))
+ ,@(maybe-list-field 'arguments
+ (append (if (not include-test-dependencies?)
+ '(#:tests? #f)
+ '())
+ (if (not (string-null? revision))
+ `(#:cabal-revision '(,revision ,cabal-hash))
+ '())))
(home-page ,(cabal-package-home-page cabal))
(synopsis ,(cabal-package-synopsis cabal))
(description ,(beautify-description (cabal-package-description cabal)))
diff --git a/tests/hackage.scm b/tests/hackage.scm
index 403f587c41..f6d91515e2 100644
--- a/tests/hackage.scm
+++ b/tests/hackage.scm
@@ -67,7 +67,7 @@ (define test-cabal-3
if impl(ghc>=7.2&&<7.6)
Build-depends: ghc-b
if impl(ghc == 7.8)
- Build-depends:
+ Build-depends:
HTTP >= 4000.2.5 && < 4000.3,
mtl >= 2.0 && < 3
")
@@ -86,7 +86,7 @@ (define test-cabal-4
if impl(ghc>=7.2&&<7.6)
Build-depends: ghc-b
if impl(ghc == 7.8)
- Build-depends:
+ Build-depends:
HTTP >= 4000.2.5 && < 4000.3,
mtl >= 2.0 && < 3
")
@@ -101,7 +101,7 @@ (define test-cabal-5
license: BSD3
library
if impl(ghc == 7.8)
- Build-depends:
+ Build-depends:
HTTP >= 4000.2.5 && < 4000.3,
if impl(ghc -any)
Build-depends: mtl >= 2.0 && < 3
@@ -126,7 +126,7 @@ (define test-cabal-6
if impl(ghc>=7.2&&<7.6)
Build-depends: ghc-b
if impl(ghc == 7.8)
- Build-depends:
+ Build-depends:
HTTP >= 4000.2.5 && < 4000.3,
mtl >= 2.0 && < 3
")
@@ -524,8 +524,9 @@ (define-package-matcher match-ghc-foo-revision
('properties '(quote ((upstream-name . "foo"))))
('inputs ('list 'ghc-http))
('arguments
- ('quasiquote
- ('#:cabal-revision
+ ('list
+ '#:cabal-revision
+ ('quote
("2" "0xxd88fb659f0krljidbvvmkh9ppjnx83j0nqzx8whcg4n5qbyng"))))
('home-page "http://test.org")
('synopsis (? string?))
--
2.45.2
H
H
Herman Rimm wrote on 24 Sep 22:13 +0200
[PATCH v3 09/11] import: cpan: Use 'maybe-upstream-inputs' procedure.
(address . 70923@debbugs.gnu.org)
bce53aae8d24b2df015c481a4fb6ab76d70f68b4.1727207512.git.herman@rimm.ee
* guix/import/cpan.scm (maybe-inputs): Delete procedure.
(cpan-module->sexp): Use 'maybe-upstream-inputs' procedure.

Change-Id: I4fa99da62d81f02c2998ad96f5ea81e27df071cd
---
guix/import/cpan.scm | 23 +++++++----------------
1 file changed, 7 insertions(+), 16 deletions(-)

Toggle diff (57 lines)
diff --git a/guix/import/cpan.scm b/guix/import/cpan.scm
index b87736eef6..611ea63eba 100644
--- a/guix/import/cpan.scm
+++ b/guix/import/cpan.scm
@@ -5,6 +5,7 @@
;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2020, 2021, 2023 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -37,7 +38,8 @@ (define-module (guix import cpan)
#:use-module (guix utils)
#:use-module (guix base32)
#:use-module ((guix download) #:select (download-to-store url-fetch))
- #:use-module ((guix import utils) #:select (factorize-uri))
+ #:use-module ((guix import utils) #:select (factorize-uri
+ maybe-upstream-inputs))
#:use-module (guix import json)
#:use-module (guix packages)
#:use-module (guix upstream)
@@ -275,15 +277,6 @@ (define (cpan-module->sexp release)
(define version (cpan-release-version release))
(define source-url (cpan-source-url release))
- (define (maybe-inputs input-type inputs)
- (match inputs
- (()
- '())
- ((inputs ...)
- `((,input-type (list ,@(map (compose string->symbol
- upstream-input-downstream-name)
- inputs)))))))
-
(let ((tarball (with-store store
(download-to-store store source-url)))
(inputs (cpan-module-inputs release)))
@@ -297,12 +290,10 @@ (define (cpan-module->sexp release)
(base32
,(bytevector->nix-base32-string (file-sha256 tarball))))))
(build-system perl-build-system)
- ,@(maybe-inputs 'native-inputs
- (filter (upstream-input-type-predicate 'native)
- inputs))
- ,@(maybe-inputs 'propagated-inputs
- (filter (upstream-input-type-predicate 'propagated)
- inputs))
+ ,@(maybe-upstream-inputs 'native-inputs
+ (filter (upstream-input-type-predicate 'native) inputs))
+ ,@(maybe-upstream-inputs 'propagated-inputs
+ (filter (upstream-input-type-predicate 'propagated) inputs))
(home-page ,(cpan-home name))
(synopsis ,(cpan-release-abstract release))
(description fill-in-yourself!)
--
2.45.2
H
H
Herman Rimm wrote on 24 Sep 22:13 +0200
[PATCH v3 10/11] import: egg: Use maybe-*inputs procedures.
(address . 70923@debbugs.gnu.org)
4bb46928e59df2b38889d6f82c60bd08419d9605.1727207512.git.herman@rimm.ee
* guix/import/egg.scm (maybe-inputs): Delete procedure.
(egg-parse-dependency): Simplify procedure to return strings.
(egg->guix-package): Use maybe-*inputs procedures.

Change-Id: Ib0a3f5b6f02912c847defd02ba7675d80005279b
---
guix/import/egg.scm | 39 +++++++++++----------------------------
1 file changed, 11 insertions(+), 28 deletions(-)

Toggle diff (81 lines)
diff --git a/guix/import/egg.scm b/guix/import/egg.scm
index e3bc158475..97d09a7c9d 100644
--- a/guix/import/egg.scm
+++ b/guix/import/egg.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2021 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -229,23 +230,14 @@ (define* (egg->guix-package name version #:key (file #f) (source #f)
(else char)))
(maybe-symbol->string name)))
- (define* (egg-parse-dependency name #:key (system? #f))
- (define extract-name
- (match-lambda
- ((name version) name)
- (name name)))
-
- (define (prettify-name name)
+ (define* (egg-parse-dependency dependency #:key (system? #f))
+ (let ((name (match dependency
+ ((name version) name)
+ (name name))))
(if system?
(prettify-system-dependency name)
- (maybe-symbol->string name)))
-
- (let ((name (prettify-name (extract-name name))))
- ;; Dependencies are sometimes specified as symbols and sometimes
- ;; as strings
- (string->symbol (string-append
- (if system? "" package-name-prefix)
- name))))
+ (string-append package-name-prefix
+ (maybe-symbol->string name)))))
(define egg-propagated-inputs
(let ((dependencies (assoc-ref egg-content 'dependencies)))
@@ -277,15 +269,6 @@ (define* (egg->guix-package name version #:key (file #f) (source #f)
test+build-dependencies))
(() '()))))
- ;; Copied from (guix import hackage).
- (define (maybe-inputs input-type inputs)
- (match inputs
- (()
- '())
- ((inputs ...)
- (list (list input-type
- `(list ,@inputs))))))
-
(values
`(package
(name ,(egg-name->guix-name name))
@@ -303,16 +286,16 @@ (define* (egg->guix-package name version #:key (file #f) (source #f)
"failed to download tar archive"))))))
(build-system chicken-build-system)
(arguments ,(list 'quasiquote (list #:egg-name name)))
- ,@(maybe-inputs 'native-inputs egg-native-inputs)
- ,@(maybe-inputs 'inputs egg-inputs)
- ,@(maybe-inputs 'propagated-inputs egg-propagated-inputs)
+ ,@(maybe-native-inputs egg-native-inputs)
+ ,@(maybe-inputs egg-inputs)
+ ,@(maybe-propagated-inputs egg-propagated-inputs)
(home-page ,egg-home-page)
(synopsis ,egg-synopsis)
(description #f)
(license ,egg-licenses))
(filter (lambda (name)
(not (member name '("srfi-4"))))
- (map (compose guix-name->egg-name symbol->string)
+ (map guix-name->egg-name
(append egg-propagated-inputs
egg-native-inputs)))))))
--
2.45.2
H
H
Herman Rimm wrote on 24 Sep 22:13 +0200
[PATCH v3 11/11] import: hexpm: Use (guix import utils) 'maybe-inputs' procedure.
(address . 70923@debbugs.gnu.org)
c5eae4ecd12f8465f296e268d04222f851f043bc.1727207512.git.herman@rimm.ee
* guix/import/hexpm.scm (maybe-inputs): Delete procedure.
(dependencies->package-names): Return strings instead of symbols.
(make-hexpm-sexp): Use 'maybe-inputs' from (guix import utils).

Change-Id: Ie7a8a630a3a9d4859453d49fdee42aa560e27f17
---
guix/import/hexpm.scm | 29 +++++++++--------------------
1 file changed, 9 insertions(+), 20 deletions(-)

Toggle diff (57 lines)
diff --git a/guix/import/hexpm.scm b/guix/import/hexpm.scm
index 71a54ba973..a7d74e24c3 100644
--- a/guix/import/hexpm.scm
+++ b/guix/import/hexpm.scm
@@ -5,6 +5,7 @@
;;; Copyright © 2019 Martin Becze <mjbecze@riseup.net>
;;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2020-2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -153,26 +154,14 @@ (define (lookup-hexpm-release version*)
;;; Converting hex.pm packages to Guix packages.
;;;
-(define (maybe-inputs package-inputs input-type)
- "Given a list of PACKAGE-INPUTS, tries to generate the 'inputs' field of a
-package definition. INPUT-TYPE, a symbol, is used to populate the name of
-the input field."
- (match package-inputs
- (()
- '())
- ((package-inputs ...)
- `((,input-type (list ,@package-inputs))))))
-
(define (dependencies->package-names names)
- "Given a list of hexpm package NAMES, returns a list of guix package names
-as symbols."
- ;; TODO: Base name on language of dependency.
- ;; The language used for implementing the dependency is not know without
- ;; recursing the dependencies. So for now assume more packages are based on
- ;; Erlang and prefix all dependencies with "erlang-" (the default).
- (map string->symbol
- (map hexpm-name->package-name
- (sort names string-ci<?))))
+ "Given a list of hexpm package NAMES, returns a list of guix package
+names."
+ ;; TODO: Base name on the programming language of the dependency.
+ ;; The language used for implementing the dependency can only be known
+ ;; by traversing the dependencies. So for now assume packages are
+ ;; based on Erlang, and prefix dependencies with "erlang-" by default.
+ (map hexpm-name->package-name (sort names string-ci<?)))
(define* (make-hexpm-sexp #:key name version tarball-url
home-page synopsis description license
@@ -194,7 +183,7 @@ (define* (make-hexpm-sexp #:key name version tarball-url
(uri (hexpm-uri ,name version))
(sha256 (base32 ,(guix-hash-url temp)))))
(build-system ,build-system)
- ,@(maybe-inputs (dependencies->package-names dependencies) 'inputs)
+ ,@(maybe-inputs (dependencies->package-names dependencies))
(synopsis ,synopsis)
(description ,(beautify-description description))
(home-page ,(match home-page
--
2.45.2
H
H
Herman Rimm wrote on 9 Dec 20:58 +0100
[PATCH v4 01/11] build-system: cargo: Accept unlabeled #:cargo-inputs.
(address . 70923@debbugs.gnu.org)
4b8cde409e17e4b9ab7ef591eff605b88235fb0a.1733774143.git.herman@rimm.ee
* guix/build-system/cargo.scm (crate-closure): Match unlabeled inputs.

Change-Id: Iae421281fa08d09ddd1e5d2da2864f0093d97cd1
---
guix/build-system/cargo.scm | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

Toggle diff (44 lines)
diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 658a2e525e..2e3061c0e8 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -6,6 +6,7 @@
;;; Copyright © 2019 Ivan Petkov <ivanppetkov@gmail.com>
;;; Copyright © 2020 Jakub K?dzio?ka <kuba@kadziolka.net>
;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -234,11 +235,14 @@ (define (crate-closure inputs)
(if (null? propagated)
(reverse result)
(loop (reverse (concatenate propagated)) result '() #f seen)))
- (((and input (label (? package? package))) rest ...)
+ ;; Match inputs with labels for backward compatibility.
+ (((or (_ (? package? package))
+ (? package? package))
+ rest ...)
(if (and (not first?) (seen? seen package))
(loop rest result propagated first? seen)
(loop rest
- (cons input result)
+ (cons package result)
(cons (package-cargo-inputs package)
propagated)
first?
@@ -296,8 +300,8 @@ (define (expand-crate-sources cargo-inputs cargo-development-inputs)
something that can always be extended or reworked in the future)."
(filter-map
(match-lambda
- ((label (? package? p))
- (list label (package-source p)))
+ ((? package? p)
+ (list (package-name p) (package-source p)))
((label input)
(list label input)))
(crate-closure (append cargo-inputs cargo-development-inputs))))

base-commit: a5a540d71331fd43fd53e23eb49102c55462c28f
--
2.45.2
H
H
Herman Rimm wrote on 9 Dec 20:58 +0100
[PATCH v4 02/11] import: utils: Emit new-style package inputs.
(address . 70923@debbugs.gnu.org)(name . Sarah Morgensen)(address . iskarian@mgsn.dev)
9e86317f85773cce9744113feb6f96fa5c462b4e.1733774143.git.herman@rimm.ee
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(-)

Toggle diff (90 lines)
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
H
H
Herman Rimm wrote on 9 Dec 20:58 +0100
[PATCH v4 04/11] import: utils: Add 'maybe-upstream-inputs' procedure.
(address . 70923@debbugs.gnu.org)
7fd481409247d1124171d1f8a5a549f6e4d92f46.1733774143.git.herman@rimm.ee
* guix/import/utils.scm (maybe-upstream-inputs): Add procedure.

Change-Id: Ib8a80216d512c0373e55e4f27e1ef2a7c1fb854a
---
guix/import/utils.scm | 9 +++++++++
1 file changed, 9 insertions(+)

Toggle diff (36 lines)
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index 4eab790645..9544fbf00f 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -45,6 +45,7 @@ (define-module (guix import utils)
#:use-module (guix download)
#:use-module (guix sets)
#:use-module ((guix ui) #:select (fill-paragraph))
+ #:use-module (guix upstream)
#:use-module (gnu packages)
#:autoload (ice-9 control) (let/ec)
#:use-module (ice-9 match)
@@ -71,6 +72,7 @@ (define-module (guix import utils)
maybe-inputs
maybe-native-inputs
maybe-propagated-inputs
+ maybe-upstream-inputs
package->definition
spdx-string->license
@@ -467,6 +469,13 @@ (define* (maybe-propagated-inputs package-names #:optional (output #f))
"MAYBE-PACKAGES-FIELD for propagated inputs."
(maybe-packages-field 'propagated-inputs package-names output))
+(define* (maybe-upstream-inputs type upstream-inputs)
+ "Given a list of UPSTREAM-NAMES, tries to generate the TYPE field of a
+package definition."
+ (maybe-list-field type
+ (map (compose string->symbol upstream-input-downstream-name)
+ upstream-inputs)))
+
(define* (package->definition guix-package #:optional append-version?/string)
"If APPEND-VERSION?/STRING is #t, append the package's major+minor version.
If it is the symbol 'full, append the package's complete version. If
--
2.45.2
H
H
Herman Rimm wrote on 9 Dec 20:58 +0100
[PATCH v4 03/11] import: crate: Emit new-style package inputs.
(address . 70923@debbugs.gnu.org)(name . Sarah Morgensen)(address . iskarian@mgsn.dev)
019ad22bc42e58a41beb87b89237f8457874682d.1733774143.git.herman@rimm.ee
From: Sarah Morgensen <iskarian@mgsn.dev>

* guix/import/crate.scm (maybe-cargo-inputs,
maybe-cargo-development-inputs, maybe-arguments): Delete procedures.
(make-crate-sexp): Add 'unwrap' procedure, use with maybe-packages-field
and fix indentation.
* tests/crate.scm: Adjust accordingly.

Change-Id: Ie8debd2553a338c3c623162b843e0a9827314074
---
guix/import/crate.scm | 51 ++++++------------
tests/crate.scm | 119 +++++++++++++++++-------------------------
2 files changed, 65 insertions(+), 105 deletions(-)

Toggle diff (314 lines)
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 5996571cda..962159f16e 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -7,6 +7,7 @@
;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2023, 2024 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2023, 2024 David Elsing <david.elsing@posteo.net>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -158,27 +159,6 @@ (define* (package-names->package-inputs names #:optional (output #f))
(input (make-input input #f)))
names))
-(define (maybe-cargo-inputs package-names)
- (match (package-names->package-inputs package-names)
- (()
- '())
- ((package-inputs ...)
- `(#:cargo-inputs ,package-inputs))))
-
-(define (maybe-cargo-development-inputs package-names)
- (match (package-names->package-inputs package-names)
- (()
- '())
- ((package-inputs ...)
- `(#:cargo-development-inputs ,package-inputs))))
-
-(define (maybe-arguments arguments)
- (match arguments
- (()
- '())
- ((args ...)
- `((arguments (,'quasiquote ,args))))))
-
(define (version->semver-prefix version)
"Return the version up to and including the first non-zero part"
(first
@@ -202,8 +182,14 @@ (define* (make-crate-sexp #:key name version cargo-inputs cargo-development-inpu
(let* ((port (http-fetch (crate-uri name version)))
(guix-name (crate-name->package-name name))
- (cargo-inputs (format-inputs cargo-inputs))
- (cargo-development-inputs (format-inputs cargo-development-inputs))
+ (unwrap (match-lambda
+ ((lst) lst)
+ (() '())))
+ (cargo-inputs (maybe-packages-field '#:cargo-inputs
+ (format-inputs cargo-inputs)))
+ (cargo-development-inputs
+ (maybe-packages-field '#:cargo-development-inputs
+ (format-inputs cargo-development-inputs)))
(description (beautify-description description))
(pkg `(package
(name ,guix-name)
@@ -222,12 +208,10 @@ (define* (make-crate-sexp #:key name version cargo-inputs cargo-development-inpu
`((properties '((crate-version-yanked? . #t))))
'())
(build-system cargo-build-system)
- ,@(maybe-arguments (append (if build?
- '()
- '(#:skip-build? #t))
- (maybe-cargo-inputs cargo-inputs)
- (maybe-cargo-development-inputs
- cargo-development-inputs)))
+ ,@(maybe-list-field 'arguments
+ (append (if build? '() '(#:skip-build? #t))
+ (unwrap cargo-inputs)
+ (unwrap cargo-development-inputs)))
(home-page ,home-page)
(synopsis ,(beautify-synopsis synopsis))
(description ,(if (string-prefix? "This" description)
@@ -239,11 +223,10 @@ (define* (make-crate-sexp #:key name version cargo-inputs cargo-development-inpu
(#f #f)
((license) license)
(_ `(list ,@license)))))))
- (close-port port)
- (package->definition pkg
- (if yanked?
- (string-append version "-yanked")
- (version->semver-prefix version)))))
+ (close-port port)
+ (package->definition pkg (if yanked?
+ (string-append version "-yanked")
+ (version->semver-prefix version)))))
(define (string->license string)
(filter-map (lambda (license)
diff --git a/tests/crate.scm b/tests/crate.scm
index 5b4ad08c3c..8e3da2e72c 100644
--- a/tests/crate.scm
+++ b/tests/crate.scm
@@ -5,6 +5,8 @@
;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
;;; Copyright © 2023 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2023 David Elsing <david.elsing@posteo.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -497,10 +499,10 @@ (define have-guile-semver?
(? string? hash)))))
(build-system 'cargo-build-system)
(arguments
- ('quasiquote
- (#:skip-build? #t
+ (list
+ #:skip-build? #t
#:cargo-inputs
- (("rust-leaf-alice" ('unquote 'rust-leaf-alice-0.7))))))
+ (list rust-leaf-alice-0.7)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -589,7 +591,7 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:skip-build? #t)))
+ (list #:skip-build? #t))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -608,7 +610,7 @@ (define have-guile-semver?
(base32
(? string? hash)))))
(build-system cargo-build-system)
- (arguments ('quasiquote (#:skip-build? #t)))
+ (arguments (list #:skip-build? #t))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -627,7 +629,7 @@ (define have-guile-semver?
(base32
(? string? hash)))))
(build-system cargo-build-system)
- (arguments ('quasiquote (#:skip-build? #t)))
+ (arguments (list #:skip-build? #t))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -647,10 +649,9 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:skip-build? #t
- #:cargo-inputs
- (("rust-leaf-bob"
- ('unquote rust-leaf-bob-3))))))
+ (list #:skip-build? #t
+ #:cargo-inputs
+ (list rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -670,14 +671,11 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:skip-build? #t
- #:cargo-inputs
- (("rust-intermediate-b"
- ('unquote rust-intermediate-b-1))
- ("rust-leaf-alice"
- ('unquote 'rust-leaf-alice-0.7))
- ("rust-leaf-bob"
- ('unquote rust-leaf-bob-3))))))
+ (list #:skip-build? #t
+ #:cargo-inputs
+ (list rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -697,18 +695,13 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-intermediate-a"
- ('unquote rust-intermediate-a-1))
- ("rust-intermediate-b"
- ('unquote rust-intermediate-b-1))
- ("rust-leaf-alice"
- ('unquote 'rust-leaf-alice-0.7))
- ("rust-leaf-bob"
- ('unquote rust-leaf-bob-3)))
- #:cargo-development-inputs
- (("rust-intermediate-c"
- ('unquote rust-intermediate-c-1))))))
+ (list #:cargo-inputs
+ (list rust-intermediate-a-1
+ rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)
+ #:cargo-development-inputs
+ ((list rust-intermediate-c-1))))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -735,9 +728,8 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-development-inputs
- (("rust-leaf-alice"
- ('unquote rust-leaf-alice-0.7))))))
+ (list #:cargo-development-inputs
+ (list rust-leaf-alice-0.7)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -793,9 +785,8 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-leaf-bob"
- ('unquote rust-leaf-bob-3))))))
+ (list #:cargo-inputs
+ (list rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -815,13 +806,10 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-intermediate-b"
- ('unquote rust-intermediate-b-1))
- ("rust-leaf-alice"
- ('unquote 'rust-leaf-alice-0.7))
- ("rust-leaf-bob"
- ('unquote rust-leaf-bob-3))))))
+ (list #:cargo-inputs
+ (list rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -841,18 +829,13 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-intermediate-a"
- ('unquote rust-intermediate-a-1))
- ("rust-intermediate-b"
- ('unquote rust-intermediate-b-1))
- ("rust-leaf-alice"
- ('unquote 'rust-leaf-alice-0.7))
- ("rust-leaf-bob"
- ('unquote rust-leaf-bob-3)))
- #:cargo-development-inputs
- (("rust-intermediate-c"
- ('unquote rust-intermediate-c-1))))))
+ (list #:cargo-inputs
+ (list rust-intermediate-a-1
+ rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)
+ #:cargo-development-inputs
+ (list rust-intermediate-c-1)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -962,14 +945,11 @@ (define rust-leaf-bob-3.0.2-yanked
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-3)))
- #:cargo-development-inputs
- (("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-3.0.2-yanked))
- ("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-4.0.0-yanked))))))
+ (list #:cargo-inputs
+ (list rust-leaf-bob-3)
+ #:cargo-development-inputs
+ (list rust-leaf-bob-3.0.2-yanked
+ rust-leaf-bob-4.0.0-yanked)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -1093,14 +1073,11 @@ (define rust-leaf-bob-3.0.2-yanked
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-3)))
- #:cargo-development-inputs
- (("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-3.0.2-yanked))
- ("rust-leaf-bob"
- ('unquote 'rust-leaf-bob-4.0.0-yanked))))))
+ (list #:cargo-inputs
+ (list rust-leaf-bob-3)
+ #:cargo-development-inputs
+ (list rust-leaf-bob-3.0.2-yanked
+ rust-leaf-bob-4.0.0-yanked)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
--
2.45.2
H
H
Herman Rimm wrote on 9 Dec 20:58 +0100
[PATCH v4 06/11] import: elpa: Use maybe-propagated-inputs procedure.
(address . 70923@debbugs.gnu.org)
1aa9a745e91fbe39f93034965451562d429e9674.1733774143.git.herman@rimm.ee
* guix/import/elpa.scm (maybe-inputs): Delete procedure.
(elpa-package->sexp): Use maybe-propagated-inputs procedure.

Change-Id: I9b40e9d387311f5dbbb079938733bf945a1a6ee6
---
guix/import/elpa.scm | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)

Toggle diff (29 lines)
diff --git a/guix/import/elpa.scm b/guix/import/elpa.scm
index 46b6dc98a2..9ade189a8a 100644
--- a/guix/import/elpa.scm
+++ b/guix/import/elpa.scm
@@ -359,13 +359,6 @@ (define* (elpa-package->sexp pkg #:optional license repo)
(map (compose string->symbol elpa-name->package-name)
dependencies-names))
- (define (maybe-inputs input-type inputs)
- (match inputs
- (()
- '())
- ((inputs ...)
- (list (list input-type `(list ,@inputs))))))
-
(define melpa-source
(melpa-recipe->origin melpa-recipe))
@@ -386,7 +379,7 @@ (define* (elpa-package->sexp pkg #:optional license repo)
(file-hash* tarball #:recursive? #false))
"failed to download package")))))))
(build-system emacs-build-system)
- ,@(maybe-inputs 'propagated-inputs dependencies)
+ ,@(maybe-propagated-inputs dependencies)
,@(if melpa-source
(melpa-recipe->maybe-arguments melpa-recipe)
'())
--
2.45.2
H
H
Herman Rimm wrote on 9 Dec 20:58 +0100
[PATCH v4 07/11] import: hackage: Use 'maybe-list-field' procedure.
(address . 70923@debbugs.gnu.org)
b436b901f754530977075111b92fa564766829f3.1733774143.git.herman@rimm.ee
* guix/import/hackage.scm (maybe-inputs, maybe-arguments): Delete
procedures.
(hackage-module->sexp): Use 'maybe-list-field' and
'maybe-upstream-inputs' procedures.
* tests/hackage.scm: Fix whitespace and replace 'quasiquote' with
'list'.

Change-Id: I4fe39ff84c9f6a677f810d9e4fe751d762973757
---
guix/import/hackage.scm | 39 ++++++++++++---------------------------
tests/hackage.scm | 13 +++++++------
2 files changed, 19 insertions(+), 33 deletions(-)

Toggle diff (118 lines)
diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm
index 422887d435..99dfb84b7d 100644
--- a/guix/import/hackage.scm
+++ b/guix/import/hackage.scm
@@ -10,6 +10,7 @@
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
;;; Copyright © 2023-2024 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2024 Nicolas Graves <ngraves@ngraves.fr>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -290,26 +291,6 @@ (define* (hackage-module->sexp cabal cabal-hash
#:include-test-dependencies?
include-test-dependencies?))
- (define (maybe-inputs input-type inputs)
- (match inputs
- (()
- '())
- ((inputs ...)
- (list (list input-type
- `(list ,@(map (compose string->symbol
- upstream-input-downstream-name)
- inputs)))))))
-
- (define (maybe-arguments)
- (match (append (if (not include-test-dependencies?)
- '(#:tests? #f)
- '())
- (if (not (string-null? revision))
- `(#:cabal-revision (,revision ,cabal-hash))
- '()))
- (() '())
- (args `((arguments (,'quasiquote ,args))))))
-
(let ((tarball (with-store store
(download-to-store store source-url))))
(values
@@ -326,13 +307,17 @@ (define* (hackage-module->sexp cabal cabal-hash
"failed to download tar archive")))))
(build-system haskell-build-system)
(properties '((upstream-name . ,name)))
- ,@(maybe-inputs 'inputs
- (filter (upstream-input-type-predicate 'regular)
- inputs))
- ,@(maybe-inputs 'native-inputs
- (filter (upstream-input-type-predicate 'native)
- inputs))
- ,@(maybe-arguments)
+ ,@(maybe-upstream-inputs 'inputs
+ (filter (upstream-input-type-predicate 'regular) inputs))
+ ,@(maybe-upstream-inputs 'native-inputs
+ (filter (upstream-input-type-predicate 'native) inputs))
+ ,@(maybe-list-field 'arguments
+ (append (if (not include-test-dependencies?)
+ '(#:tests? #f)
+ '())
+ (if (not (string-null? revision))
+ `(#:cabal-revision '(,revision ,cabal-hash))
+ '())))
(home-page ,(cabal-package-home-page cabal))
(synopsis ,(cabal-package-synopsis cabal))
(description ,(beautify-description (cabal-package-description cabal)))
diff --git a/tests/hackage.scm b/tests/hackage.scm
index 403f587c41..f6d91515e2 100644
--- a/tests/hackage.scm
+++ b/tests/hackage.scm
@@ -67,7 +67,7 @@ (define test-cabal-3
if impl(ghc>=7.2&&<7.6)
Build-depends: ghc-b
if impl(ghc == 7.8)
- Build-depends:
+ Build-depends:
HTTP >= 4000.2.5 && < 4000.3,
mtl >= 2.0 && < 3
")
@@ -86,7 +86,7 @@ (define test-cabal-4
if impl(ghc>=7.2&&<7.6)
Build-depends: ghc-b
if impl(ghc == 7.8)
- Build-depends:
+ Build-depends:
HTTP >= 4000.2.5 && < 4000.3,
mtl >= 2.0 && < 3
")
@@ -101,7 +101,7 @@ (define test-cabal-5
license: BSD3
library
if impl(ghc == 7.8)
- Build-depends:
+ Build-depends:
HTTP >= 4000.2.5 && < 4000.3,
if impl(ghc -any)
Build-depends: mtl >= 2.0 && < 3
@@ -126,7 +126,7 @@ (define test-cabal-6
if impl(ghc>=7.2&&<7.6)
Build-depends: ghc-b
if impl(ghc == 7.8)
- Build-depends:
+ Build-depends:
HTTP >= 4000.2.5 && < 4000.3,
mtl >= 2.0 && < 3
")
@@ -524,8 +524,9 @@ (define-package-matcher match-ghc-foo-revision
('properties '(quote ((upstream-name . "foo"))))
('inputs ('list 'ghc-http))
('arguments
- ('quasiquote
- ('#:cabal-revision
+ ('list
+ '#:cabal-revision
+ ('quote
("2" "0xxd88fb659f0krljidbvvmkh9ppjnx83j0nqzx8whcg4n5qbyng"))))
('home-page "http://test.org")
('synopsis (? string?))
--
2.45.2
H
H
Herman Rimm wrote on 9 Dec 20:58 +0100
[PATCH v4 08/11] import: cran: Use 'maybe-list-field' procedure.
(address . 70923@debbugs.gnu.org)
ffca10726eee00287a2f7470651c867486fae72a.1733774143.git.herman@rimm.ee
* guix/import/cran.scm (format-inputs): Delete procedure.
(maybe-inputs): Use 'maybe-list-field' procedure.

Change-Id: I5148afcebdac1f7fa0f8cce9e82e8cebb56c36c8
---
guix/import/cran.scm | 36 ++++++++++++++++--------------------
1 file changed, 16 insertions(+), 20 deletions(-)

Toggle diff (63 lines)
diff --git a/guix/import/cran.scm b/guix/import/cran.scm
index fe69cb87f7..11843703ac 100644
--- a/guix/import/cran.scm
+++ b/guix/import/cran.scm
@@ -6,6 +6,7 @@
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -86,21 +87,6 @@ (define-module (guix import cran)
(define %input-style
(make-parameter 'variable)) ; or 'specification
-(define (format-inputs inputs)
- "Generate a sorted list of package inputs from a list of upstream inputs."
- (map (lambda (input)
- (case (%input-style)
- ((specification)
- `(specification->package ,(upstream-input-downstream-name input)))
- (else
- ((compose string->symbol
- upstream-input-downstream-name)
- input))))
- (sort inputs
- (lambda (a b)
- (string-ci<? (upstream-input-name a)
- (upstream-input-name b))))))
-
(define (string->licenses license-string license-prefix)
(let ((licenses
(map string-trim-both
@@ -189,11 +175,21 @@ (define (description->alist description)
(define* (maybe-inputs package-inputs #:optional (input-type 'inputs))
"Given a list of PACKAGE-INPUTS, tries to generate the TYPE field of a
package definition."
- (match package-inputs
- (()
- '())
- ((package-inputs ...)
- `((,input-type (list ,@(format-inputs package-inputs)))))))
+ (define (format-input input)
+ (case (%input-style)
+ ((specification)
+ `(specification->package ,(upstream-input-downstream-name input)))
+ (else
+ ((compose string->symbol
+ upstream-input-downstream-name)
+ input))))
+
+ (define (upstream-input-name<? i1 i2)
+ (string-ci<? (upstream-input-name i1)
+ (upstream-input-name i2)))
+
+ (maybe-list-field input-type
+ (map format-input (sort package-inputs upstream-input-name<?))))
(define %cran-url "https://cloud.r-project.org/web/packages/")
(define %cran-canonical-url "https://cran.r-project.org/package=")
--
2.45.2
H
H
Herman Rimm wrote on 9 Dec 20:58 +0100
[PATCH v4 09/11] import: cpan: Use 'maybe-upstream-inputs' procedure.
(address . 70923@debbugs.gnu.org)
f56be2988f28396b31e63eed1360d7d6a6826410.1733774143.git.herman@rimm.ee
* guix/import/cpan.scm (maybe-inputs): Delete procedure.
(cpan-module->sexp): Use 'maybe-upstream-inputs' procedure.

Change-Id: I4fa99da62d81f02c2998ad96f5ea81e27df071cd
---
guix/import/cpan.scm | 25 ++++++++-----------------
1 file changed, 8 insertions(+), 17 deletions(-)

Toggle diff (59 lines)
diff --git a/guix/import/cpan.scm b/guix/import/cpan.scm
index 85e5e69098..e26cc85491 100644
--- a/guix/import/cpan.scm
+++ b/guix/import/cpan.scm
@@ -5,6 +5,7 @@
;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2020, 2021, 2023 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -37,8 +38,9 @@ (define-module (guix import cpan)
#:use-module (guix utils)
#:use-module (guix base32)
#:use-module ((guix download) #:select (download-to-store url-fetch))
- #:use-module ((guix import utils)
- #:select (factorize-uri recursive-import))
+ #:use-module ((guix import utils) #:select (factorize-uri
+ maybe-upstream-inputs
+ recursive-import))
#:use-module (guix import json)
#:use-module (guix packages)
#:use-module (guix upstream)
@@ -277,15 +279,6 @@ (define (cpan-module->sexp release)
(define version (cpan-release-version release))
(define source-url (cpan-source-url release))
- (define (maybe-inputs input-type inputs)
- (match inputs
- (()
- '())
- ((inputs ...)
- `((,input-type (list ,@(map (compose string->symbol
- upstream-input-downstream-name)
- inputs)))))))
-
(let* ((tarball (with-store store
(download-to-store store source-url)))
(inputs (cpan-module-inputs release))
@@ -300,12 +293,10 @@ (define (cpan-module->sexp release)
(base32
,(bytevector->nix-base32-string (file-sha256 tarball))))))
(build-system perl-build-system)
- ,@(maybe-inputs 'native-inputs
- (filter (upstream-input-type-predicate 'native)
- inputs))
- ,@(maybe-inputs 'propagated-inputs
- (filter (upstream-input-type-predicate 'propagated)
- inputs))
+ ,@(maybe-upstream-inputs 'native-inputs
+ (filter (upstream-input-type-predicate 'native) inputs))
+ ,@(maybe-upstream-inputs 'propagated-inputs
+ (filter (upstream-input-type-predicate 'propagated) inputs))
(home-page ,(cpan-home name))
(synopsis ,(cpan-release-abstract release))
(description fill-in-yourself!)
--
2.45.2
H
H
Herman Rimm wrote on 9 Dec 20:58 +0100
[PATCH v4 10/11] import: egg: Use maybe-*inputs procedures.
(address . 70923@debbugs.gnu.org)
889b96cf8b0b08a11e116f67b836f9efd209b9e9.1733774143.git.herman@rimm.ee
* guix/import/egg.scm (maybe-inputs): Delete procedure.
(egg-parse-dependency): Simplify procedure to return strings.
(egg->guix-package): Use maybe-*inputs procedures.

Change-Id: Ib0a3f5b6f02912c847defd02ba7675d80005279b
---
guix/import/egg.scm | 39 +++++++++++----------------------------
1 file changed, 11 insertions(+), 28 deletions(-)

Toggle diff (81 lines)
diff --git a/guix/import/egg.scm b/guix/import/egg.scm
index a87de1453e..049c45257e 100644
--- a/guix/import/egg.scm
+++ b/guix/import/egg.scm
@@ -4,6 +4,7 @@
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
;;; Copyright © 2024 Ekaitz Zarraga <ekaitz@elenq.tech>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -230,23 +231,14 @@ (define* (egg->guix-package name version #:key (file #f) (source #f)
(else char)))
(maybe-symbol->string name)))
- (define* (egg-parse-dependency name #:key (system? #f))
- (define extract-name
- (match-lambda
- ((name version) name)
- (name name)))
-
- (define (prettify-name name)
+ (define* (egg-parse-dependency dependency #:key (system? #f))
+ (let ((name (match dependency
+ ((name version) name)
+ (name name))))
(if system?
(prettify-system-dependency name)
- (maybe-symbol->string name)))
-
- (let ((name (prettify-name (extract-name name))))
- ;; Dependencies are sometimes specified as symbols and sometimes
- ;; as strings
- (string->symbol (string-append
- (if system? "" package-name-prefix)
- name))))
+ (string-append package-name-prefix
+ (maybe-symbol->string name)))))
(define egg-propagated-inputs
(let ((dependencies (assoc-ref egg-content 'dependencies)))
@@ -278,15 +270,6 @@ (define* (egg->guix-package name version #:key (file #f) (source #f)
test+build-dependencies))
(() '()))))
- ;; Copied from (guix import hackage).
- (define (maybe-inputs input-type inputs)
- (match inputs
- (()
- '())
- ((inputs ...)
- (list (list input-type
- `(list ,@inputs))))))
-
(values
`(package
(name ,(egg-name->guix-name name))
@@ -304,16 +287,16 @@ (define* (egg->guix-package name version #:key (file #f) (source #f)
"failed to download tar archive"))))))
(build-system chicken-build-system)
(arguments ,(list 'quasiquote (list #:egg-name name)))
- ,@(maybe-inputs 'native-inputs egg-native-inputs)
- ,@(maybe-inputs 'inputs egg-inputs)
- ,@(maybe-inputs 'propagated-inputs egg-propagated-inputs)
+ ,@(maybe-native-inputs egg-native-inputs)
+ ,@(maybe-inputs egg-inputs)
+ ,@(maybe-propagated-inputs egg-propagated-inputs)
(home-page ,egg-home-page)
(synopsis ,egg-synopsis)
(description #f)
(license ,egg-licenses))
(filter (lambda (name)
(not (member name '("srfi-4"))))
- (map (compose guix-name->egg-name symbol->string)
+ (map guix-name->egg-name
(append egg-propagated-inputs
egg-native-inputs)))))))
--
2.45.2
H
H
Herman Rimm wrote on 9 Dec 20:58 +0100
[PATCH v4 11/11] import: hexpm: Use (guix import utils) 'maybe-inputs' procedure.
(address . 70923@debbugs.gnu.org)
5cee288aa6676f609297e7599a9f121886d8d6a7.1733774143.git.herman@rimm.ee
* guix/import/hexpm.scm (maybe-inputs): Delete procedure.
(dependencies->package-names): Return strings instead of symbols.
(make-hexpm-sexp): Use 'maybe-inputs' from (guix import utils).

Change-Id: Ie7a8a630a3a9d4859453d49fdee42aa560e27f17
---
guix/import/hexpm.scm | 29 +++++++++--------------------
1 file changed, 9 insertions(+), 20 deletions(-)

Toggle diff (57 lines)
diff --git a/guix/import/hexpm.scm b/guix/import/hexpm.scm
index 71a54ba973..a7d74e24c3 100644
--- a/guix/import/hexpm.scm
+++ b/guix/import/hexpm.scm
@@ -5,6 +5,7 @@
;;; Copyright © 2019 Martin Becze <mjbecze@riseup.net>
;;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2020-2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -153,26 +154,14 @@ (define (lookup-hexpm-release version*)
;;; Converting hex.pm packages to Guix packages.
;;;
-(define (maybe-inputs package-inputs input-type)
- "Given a list of PACKAGE-INPUTS, tries to generate the 'inputs' field of a
-package definition. INPUT-TYPE, a symbol, is used to populate the name of
-the input field."
- (match package-inputs
- (()
- '())
- ((package-inputs ...)
- `((,input-type (list ,@package-inputs))))))
-
(define (dependencies->package-names names)
- "Given a list of hexpm package NAMES, returns a list of guix package names
-as symbols."
- ;; TODO: Base name on language of dependency.
- ;; The language used for implementing the dependency is not know without
- ;; recursing the dependencies. So for now assume more packages are based on
- ;; Erlang and prefix all dependencies with "erlang-" (the default).
- (map string->symbol
- (map hexpm-name->package-name
- (sort names string-ci<?))))
+ "Given a list of hexpm package NAMES, returns a list of guix package
+names."
+ ;; TODO: Base name on the programming language of the dependency.
+ ;; The language used for implementing the dependency can only be known
+ ;; by traversing the dependencies. So for now assume packages are
+ ;; based on Erlang, and prefix dependencies with "erlang-" by default.
+ (map hexpm-name->package-name (sort names string-ci<?)))
(define* (make-hexpm-sexp #:key name version tarball-url
home-page synopsis description license
@@ -194,7 +183,7 @@ (define* (make-hexpm-sexp #:key name version tarball-url
(uri (hexpm-uri ,name version))
(sha256 (base32 ,(guix-hash-url temp)))))
(build-system ,build-system)
- ,@(maybe-inputs (dependencies->package-names dependencies) 'inputs)
+ ,@(maybe-inputs (dependencies->package-names dependencies))
(synopsis ,synopsis)
(description ,(beautify-description description))
(home-page ,(match home-page
--
2.45.2
H
H
Herman Rimm wrote on 9 Dec 20:58 +0100
[PATCH v4 05/11] import: pypi: Use 'maybe-list-field' procedure.
(address . 70923@debbugs.gnu.org)
edc5d31b7f0378fc7fed8f64e7a4d23b28ab76d3.1733774143.git.herman@rimm.ee
* guix/import/pypi.scm (maybe-inputs): Delete procedure.
(make-pypi-sexp): Use 'maybe-list-field' and 'maybe-upstream-inputs'
procedures.
---
guix/import/pypi.scm | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)

Toggle diff (48 lines)
diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm
index 7b9f54a200..a98fdfa604 100644
--- a/guix/import/pypi.scm
+++ b/guix/import/pypi.scm
@@ -14,6 +14,7 @@
;;; Copyright © 2022 Vivien Kraus <vivien@planete-kraus.eu>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -201,18 +202,6 @@ (define (wheel-url->extracted-directory wheel-url)
((name version _ ...)
(string-append name "-" version ".dist-info"))))
-(define (maybe-inputs package-inputs input-type)
- "Given a list of PACKAGE-INPUTS, tries to generate the 'inputs' field of a
-package definition. INPUT-TYPE, a symbol, is used to populate the name of
-the input field."
- (match package-inputs
- (()
- '())
- ((package-inputs ...)
- `((,input-type (list ,@(map (compose string->symbol
- upstream-input-downstream-name)
- package-inputs)))))))
-
(define %requirement-name-regexp
;; Regexp to match the requirement name in a requirement specification.
@@ -538,10 +527,10 @@ (define* (make-pypi-sexp pypi-package
bytevector->nix-base32-string)))))
,@(maybe-upstream-name name)
(build-system pyproject-build-system)
- ,@(maybe-inputs (upstream-source-propagated-inputs source)
- 'propagated-inputs)
- ,@(maybe-inputs (upstream-source-native-inputs source)
- 'native-inputs)
+ ,@(maybe-upstream-inputs 'propagated-inputs
+ (upstream-source-propagated-inputs source))
+ ,@(maybe-upstream-inputs 'native-inputs
+ (upstream-source-native-inputs source))
(home-page ,(project-info-home-page info))
(synopsis ,(project-info-summary info))
(description ,(and=> (non-empty-string-or-false
--
2.45.2
E
E
Efraim Flashner wrote on 10 Dec 16:41 +0100
Re: [bug#70923] [PATCH v4 01/11] build-system: cargo: Accept unlabeled #:cargo-inputs.
(name . Herman Rimm)(address . herman@rimm.ee)(address . 70923@debbugs.gnu.org)
Z1hhJyHUOEx6GClQ@3900XT
I've applied this one for now to the rust-team branch since it'll cause
a rebuild if applied to master.

I tried out the patches for the importer too, but I think with the
changes it needs the input from some other teams too?

On Mon, Dec 09, 2024 at 08:58:05PM +0100, Herman Rimm wrote:
Toggle quote (55 lines)
> * guix/build-system/cargo.scm (crate-closure): Match unlabeled inputs.
>
> Change-Id: Iae421281fa08d09ddd1e5d2da2864f0093d97cd1
> ---
> guix/build-system/cargo.scm | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
> index 658a2e525e..2e3061c0e8 100644
> --- a/guix/build-system/cargo.scm
> +++ b/guix/build-system/cargo.scm
> @@ -6,6 +6,7 @@
> ;;; Copyright © 2019 Ivan Petkov <ivanppetkov@gmail.com>
> ;;; Copyright © 2020 Jakub K?dzio?ka <kuba@kadziolka.net>
> ;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
> +;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
> ;;;
> ;;; This file is part of GNU Guix.
> ;;;
> @@ -234,11 +235,14 @@ (define (crate-closure inputs)
> (if (null? propagated)
> (reverse result)
> (loop (reverse (concatenate propagated)) result '() #f seen)))
> - (((and input (label (? package? package))) rest ...)
> + ;; Match inputs with labels for backward compatibility.
> + (((or (_ (? package? package))
> + (? package? package))
> + rest ...)
> (if (and (not first?) (seen? seen package))
> (loop rest result propagated first? seen)
> (loop rest
> - (cons input result)
> + (cons package result)
> (cons (package-cargo-inputs package)
> propagated)
> first?
> @@ -296,8 +300,8 @@ (define (expand-crate-sources cargo-inputs cargo-development-inputs)
> something that can always be extended or reworked in the future)."
> (filter-map
> (match-lambda
> - ((label (? package? p))
> - (list label (package-source p)))
> + ((? package? p)
> + (list (package-name p) (package-source p)))
> ((label input)
> (list label input)))
> (crate-closure (append cargo-inputs cargo-development-inputs))))
>
> base-commit: a5a540d71331fd43fd53e23eb49102c55462c28f
> --
> 2.45.2
>
>
>

--
Efraim Flashner <efraim@flashner.co.il> ????? ?????
GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAmdYYScACgkQQarn3Mo9
g1GR7g/+MqpHDQFNX7+bvh9DutJhSNs9ib7/cNJfmqEi0JUC/Fh4CFQj2i9+Uvtw
6JUCW6X5L5p0wE8fQs4RVgsDsOPx0P7Qd9MoVKF12GIJSuhupUyMDiW+5iEu9Zq+
kRqQTYkM9qnvZ5WAGIikZvZw/Bu3440hffDTFWEFL696g0KAJr4x7GXwd0TfwrRP
qfmUjKGvpnkobqMUqx9P/mu7zAczNDVQge1tRGFDLOQZr8aiaIMnoRbA3bWLunst
LjDXIRhbhyns+rWpwACT0GiVIb88oydWAhT1wnjPwm4DsQhrs2bz6UUI9Dythpgh
4pzCXc3zrV9cDQklejIp54KcN07LdFGe1L2zPUQkxn41rvoDTwL555TuKW72Ne78
qkp6FZIckeWBjZJ+caRB7NuSIHOEVYnPZqz+Z8WJVlhZ5FJSSjeTB2txqK/VR1rJ
WLKCZUXJb6N+Z7Ur8jealQjEWd+CkDkDilfuzhEJx2X6D7nx7usWY0GpWar4b8st
5JNUpyv3tzVcCbv7WcraCqVor4lW1WI/SzOPdKbGJxnZe+tx+8nOX4YX+U11gMDp
mwdN0TXhLbDbr9ZkAEhQjFeNfWUqDXoo7/m6EcoShjkmNqrJRV2kbAp5cad5+6OW
bdlFO/eGYsFea7WsQNV4RW7SsvaTrMiV5kqQpJyjqO6tSuBIUT0=
=IchR
-----END PGP SIGNATURE-----


L
L
Lars-Dominik Braun wrote on 10 Dec 18:35 +0100
Re: [bug#70923] [PATCH v4 07/11] import: hackage: Use 'maybe-list-field' procedure.
(name . Herman Rimm)(address . herman@rimm.ee)(address . 70923@debbugs.gnu.org)
Z1h73vwqQ2oIprUj@noor.fritz.box
Hi,

Toggle quote (39 lines)
> --- a/tests/hackage.scm
> +++ b/tests/hackage.scm
> @@ -67,7 +67,7 @@ (define test-cabal-3
> if impl(ghc>=7.2&&<7.6)
> Build-depends: ghc-b
> if impl(ghc == 7.8)
> - Build-depends:
> + Build-depends:
> HTTP >= 4000.2.5 && < 4000.3,
> mtl >= 2.0 && < 3
> ")
> @@ -86,7 +86,7 @@ (define test-cabal-4
> if impl(ghc>=7.2&&<7.6)
> Build-depends: ghc-b
> if impl(ghc == 7.8)
> - Build-depends:
> + Build-depends:
> HTTP >= 4000.2.5 && < 4000.3,
> mtl >= 2.0 && < 3
> ")
> @@ -101,7 +101,7 @@ (define test-cabal-5
> license: BSD3
> library
> if impl(ghc == 7.8)
> - Build-depends:
> + Build-depends:
> HTTP >= 4000.2.5 && < 4000.3,
> if impl(ghc -any)
> Build-depends: mtl >= 2.0 && < 3
> @@ -126,7 +126,7 @@ (define test-cabal-6
> if impl(ghc>=7.2&&<7.6)
> Build-depends: ghc-b
> if impl(ghc == 7.8)
> - Build-depends:
> + Build-depends:
> HTTP >= 4000.2.5 && < 4000.3,
> mtl >= 2.0 && < 3
> ")

why are these changes to the tests required? Having a space after the
colon is legal as far as I know.

Lars
H
H
Herman Rimm wrote on 12 Dec 22:34 +0100
(name . Lars-Dominik Braun)(address . lars@6xq.net)(address . 70923@debbugs.gnu.org)
vnzypep2s7hmjbmcduphjtbgqaj6rmukq2drn6hkhqgppiboq2@5b3ml2vxlu3x
Hello,

On Tue, Dec 10, 2024 at 06:35:26PM +0100, Lars-Dominik Braun wrote:
Toggle quote (3 lines)
> why are these changes to the tests required? Having a space after the
> colon is legal as far as I know.

Removing the trailing whitespace is not required. It doesn't change the
test results.

Cheers,
Herman
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 70923@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 70923
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch