From: "Jørgen Kvalsvik" <j@lambda.is>
To: 74371@debbugs.gnu.org
Cc: "Jørgen Kvalsvik" <j@lambda.is>
Subject: [bug#74371] [PATCH 3/4] guix: Add module aware 'guix import go'
Date: Fri, 15 Nov 2024 22:11:05 +0100 [thread overview]
Message-ID: <20241115211106.2759121-4-j@lambda.is> (raw)
In-Reply-To: <20241115211106.2759121-1-j@lambda.is>
Emit module aware package go packages. It does not compute the hash of the
full module yet, and only supports git, but goes a long way towards making it
easy to package new go programs using the module-aware build system.
* guix/import/go.scm (go-module->guix-package): Add go.mod awareness
* guix/scripts/import/go.scm (show-help): Document -m, --mod
(%options): Accept them.
Change-Id: I4efd7260d69276279940e21698ecc7eb57232a67
---
guix/import/go.scm | 88 ++++++++++++++++++++++++--------------
guix/scripts/import/go.scm | 6 +++
2 files changed, 61 insertions(+), 33 deletions(-)
diff --git a/guix/import/go.scm b/guix/import/go.scm
index dd9298808d..967aa54d58 100644
--- a/guix/import/go.scm
+++ b/guix/import/go.scm
@@ -615,6 +615,7 @@ (define (validate-version version available-versions module-path)
(define* (go-module->guix-package module-path #:key
(goproxy "https://proxy.golang.org")
version
+ go-mod?
pin-versions?
#:allow-other-keys)
"Return the package S-expression corresponding to MODULE-PATH at VERSION, a Go package.
@@ -641,43 +642,62 @@ (define* (go-module->guix-package module-path #:key
(meta-data (fetch-module-meta-data root-module-path))
(vcs-type (module-meta-vcs meta-data))
(vcs-repo-url (module-meta-data-repo-url meta-data goproxy))
+ (home-page (format #f "https://~a" root-module-path))
(synopsis (go-package-synopsis module-path))
- (description (go-package-description module-path))
- (licenses (go-package-licenses module-path)))
- (values
- `(package
- (name ,guix-name)
- (version ,(strip-v-prefix version*))
- (source
- ,(vcs->origin vcs-type vcs-repo-url version*))
- (build-system go-build-system)
- (arguments
- (list ,@(if (version>? min-go-version (package-version (go-package)))
- `(#:go ,(string->number min-go-version))
- '())
- #:import-path ,module-path
- ,@(if (string=? module-path-sans-suffix root-module-path)
- '()
- `(#:unpack-path ,root-module-path))))
- ,@(maybe-propagated-inputs
- (map (match-lambda
- ((name version)
- (go-module->guix-package-name name (strip-v-prefix version)))
- (name
- (go-module->guix-package-name name)))
- dependencies))
- (home-page ,(format #f "https://~a" root-module-path))
- (synopsis ,synopsis)
- (description ,(and=> description beautify-description))
- (license ,(match (list->licenses licenses)
+ (description (and=> (go-package-description module-path) beautify-description))
+ (licenses (go-package-licenses module-path))
+ (license (match (list->licenses licenses)
(() #f) ;unknown license
- ((license) ;a single license
- license)
+ ((license) license) ;a single license
((license ...) ;a list of licenses
`(list ,@license)))))
- (if pin-versions?
- dependencies+versions
- dependencies))))
+ (if go-mod?
+ (values
+ `(package
+ (name ,guix-name)
+ (version ,(strip-v-prefix version*))
+ (source
+ (origin
+ (method go-mod-fetch)
+ (uri (go-mod-reference
+ (source ,(vcs->origin vcs-type vcs-repo-url version*))))
+ (sha256
+ (base32
+ ;; FIXME: fetch & compute checksum
+ "0000000000000000000000000000000000000000000000000000"))))
+ (build-system go-mod-build-system)
+ (home-page ,home-page)
+ (synopsis ,synopsis)
+ (description ,description)
+ (license ,license)))
+ (values
+ `(package
+ (name ,guix-name)
+ (version ,(strip-v-prefix version*))
+ (source ,(vcs->origin vcs-type vcs-repo-url version*))
+ (build-system go-build-system)
+ (arguments
+ (list ,@(if (version>? min-go-version (package-version (go-package)))
+ `(#:go ,(string->number min-go-version))
+ '())
+ #:import-path ,module-path
+ ,@(if (string=? module-path-sans-suffix root-module-path)
+ '()
+ `(#:unpack-path ,root-module-path))))
+ ,@(maybe-propagated-inputs
+ (map (match-lambda
+ ((name version)
+ (go-module->guix-package-name name (strip-v-prefix version)))
+ (name
+ (go-module->guix-package-name name)))
+ dependencies))
+ (home-page ,home-page)
+ (synopsis ,synopsis)
+ (description ,description)
+ (license ,license)
+ (if pin-versions?
+ dependencies+versions
+ dependencies))))))
(define go-module->guix-package*
(lambda args
@@ -699,6 +719,7 @@ (define go-module->guix-package*
(define* (go-module-recursive-import package-name
#:key (goproxy "https://proxy.golang.org")
version
+ go-mod?
pin-versions?)
(recursive-import
@@ -709,6 +730,7 @@ (define* (go-module-recursive-import package-name
(receive (package-sexp dependencies)
(go-module->guix-package* name #:goproxy goproxy
#:version version
+ #:go-mod? go-mod?
#:pin-versions? pin-versions?)
(values package-sexp dependencies))))
#:guix-name go-module->guix-package-name
diff --git a/guix/scripts/import/go.scm b/guix/scripts/import/go.scm
index b90c6ac72f..a12c3a9b2f 100644
--- a/guix/scripts/import/go.scm
+++ b/guix/scripts/import/go.scm
@@ -50,6 +50,8 @@ (define (show-help)
(display (G_ "
-h, --help display this help and exit"))
(display (G_ "
+ -m, --mod generate go-module based packages"))
+ (display (G_ "
-r, --recursive generate package expressions for all Go modules
that are not yet in Guix"))
(display (G_ "
@@ -65,6 +67,9 @@ (define %options
(lambda args
(show-help)
(exit 0)))
+ (option '(#\m "mod") #f #f
+ (lambda (opt name arg result)
+ (alist-cons 'go-mod? #t result)))
(option '(#\r "recursive") #f #f
(lambda (opt name arg result)
(alist-cons 'recursive #t result)))
@@ -106,6 +111,7 @@ (define (parse-options)
(let ((arguments (list name
#:goproxy (assoc-ref opts 'goproxy)
#:version version
+ #:go-mod? (assoc-ref opts 'go-mod?)
#:pin-versions?
(assoc-ref opts 'pin-versions?))))
(if (assoc-ref opts 'recursive)
--
2.39.5
next prev parent reply other threads:[~2024-11-15 21:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-15 21:11 [bug#74370] [PATCH 0/4] Module aware go build system, downloader Jørgen Kvalsvik
2024-11-15 21:11 ` [bug#74372] [PATCH 1/4] guix: Add go module fetcher Jørgen Kvalsvik
2024-11-15 21:11 ` [bug#74374] [PATCH 2/4] guix: add go module aware build system Jørgen Kvalsvik
2024-11-15 21:11 ` Jørgen Kvalsvik [this message]
2024-11-15 21:11 ` [bug#74373] [PATCH 4/4] gnu: Add go-buf Jørgen Kvalsvik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241115211106.2759121-4-j@lambda.is \
--to=j@lambda.is \
--cc=74371@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).