diff options
| author | Hilton Chain <hako@ultrarare.space> | 2025-10-30 22:04:16 +0800 |
|---|---|---|
| committer | Hilton Chain <hako@ultrarare.space> | 2025-10-30 22:48:30 +0800 |
| commit | 97a989b8fd108876b1694821216847a1bb154c24 (patch) | |
| tree | 56c0ad6f2da16810c75f2ee01a76d1b2561424e7 | |
| parent | ebf01f03ffaf9480e68be85ced2586235e5bd3a7 (diff) | |
nonguix: download: Add go-mod-vendor.
* nonguix/download.scm (go-mod-vendor): New procedure.
| -rw-r--r-- | nonguix/download.scm | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/nonguix/download.scm b/nonguix/download.scm index 0eb661a..caf52c7 100644 --- a/nonguix/download.scm +++ b/nonguix/download.scm @@ -2,12 +2,56 @@ ;;; Copyright © 2019 Julien Lepiller <julien@lepiller.eu> (define-module (nonguix download) + #:use-module (guix build-system gnu) #:use-module (guix derivations) + #:use-module (guix gexp) #:use-module (guix monads) #:use-module (guix packages) #:use-module (guix store) #:use-module (ice-9 match) - #:export (unredistributable-url-fetch)) + #:export (go-mod-vendor + unredistributable-url-fetch)) + +(define* (go-mod-vendor #:key go) + (lambda* (src hash-algo hash #:optional name #:key (system (%current-system))) + "Return a fixed-output derivation to run \"go mod vendor\" against SRC and +use the produced \"vendor\" directory as the result. The derivation is expected +to have HASH of type HASH-ALGO (a symbol). File name of the derivation defaults +to \"vendored-go-dependencies\" and can be specified by NAME." + + (define nss-certs + (module-ref (resolve-interface '(gnu packages nss)) 'nss-certs)) + + (gexp->derivation + (or name "vendored-go-dependencies") + (with-imported-modules %default-gnu-imported-modules + #~(begin + (use-modules (guix build gnu-build-system) + (guix build utils)) + ;; Support Unicode in file name. + (setlocale LC_ALL "C.UTF-8") + ;; Use our bundled Go toolchain. + (setenv "GOTOOLCHAIN" "local") + ;; HTTPS support. + (setenv "SSL_CERT_DIR" #+(file-append nss-certs "/etc/ssl/certs")) + + ((assoc-ref %standard-phases 'unpack) #:source #+src) + (invoke #+(file-append go "/bin/go") "mod" "vendor") + (copy-recursively "vendor" #$output))) + #:system system + #:hash-algo hash-algo + #:hash hash + ;; Is a directory. + #:recursive? #t + #:env-vars + '(("GOCACHE" . "/tmp/go-cache") + ("GOPATH" . "/tmp/go")) + ;; Honor the user's proxy and locale settings. + #:leaked-env-vars + '("GOPROXY" + "http_proxy" "https_proxy" + "LC_ALL" "LC_MESSAGES" "LANG" + "COLUMNS")))) (define* (unredistributable-url-fetch url hash-algo hash #:optional name |
