diff options
author | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2022-01-25 22:07:13 -0500 |
---|---|---|
committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2022-01-25 22:07:13 -0500 |
commit | 1a5302435ff0d2822b823f5a6fe01faa7a85c629 (patch) | |
tree | ac7810c88b560532f22d2bab2e59609cd7305c21 /guix/build/go-build-system.scm | |
parent | 3ff2ac4980dacf10087e4b42bd9fbc490591900c (diff) | |
parent | 070b8a893febd6e7d8b2b7c8c4dcebacf7845aa9 (diff) |
Merge branch 'master' into staging.
With "conflicts" solved (all in favor of master except git) in:
gnu/local.mk
gnu/packages/databases.scm
gnu/packages/glib.scm
gnu/packages/gnome.scm
gnu/packages/gnupg.scm
gnu/packages/gnuzilla.scm
gnu/packages/graphics.scm
gnu/packages/gstreamer.scm
gnu/packages/gtk.scm
gnu/packages/linux.scm
gnu/packages/machine-learning.scm
gnu/packages/networking.scm
gnu/packages/polkit.scm
gnu/packages/pulseaudio.scm
gnu/packages/rpc.scm
gnu/packages/rust.scm
gnu/packages/version-control.scm
gnu/packages/w3m.scm
Diffstat (limited to 'guix/build/go-build-system.scm')
-rw-r--r-- | guix/build/go-build-system.scm | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.scm index 645d2fe680..7f25e05d0d 100644 --- a/guix/build/go-build-system.scm +++ b/guix/build/go-build-system.scm @@ -5,6 +5,7 @@ ;;; Copyright © 2020 Jack Hill <jackhill@jackhill.us> ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net> ;;; Copyright © 2020, 2021 Efraim Flashner <efraim@flashner.co.il> +;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev> ;;; ;;; This file is part of GNU Guix. ;;; @@ -138,9 +139,28 @@ of the package being built and its dependencies, and GOBIN, which determines where executables (\"commands\") are installed to. This phase is sometimes used by packages that use (guix build-system gnu) but have a handful of Go dependencies, so it should be self-contained." - ;; The Go cache is required starting in Go 1.12. We don't actually use it but - ;; we need it to be a writable directory. - (setenv "GOCACHE" "/tmp/go-cache") + (define (search-input-directories dir) + (filter directory-exists? + (map (match-lambda + ((name . directory) + (string-append directory "/" dir))) + inputs))) + + ;; Seed the Go build cache with the build caches from input packages. + (let ((cache (string-append (getcwd) "/go-build"))) + (setenv "GOCACHE" cache) + (union-build cache + (search-input-directories "/var/cache/go/build") + ;; Creating all directories isn't that bad, because there are + ;; only ever 256 of them. + #:create-all-directories? #t + #:log-port (%make-void-port "w")) + + ;; Tell Go that the cache was recently trimmed, so it doesn't try to. + (call-with-output-file (string-append cache "/trim.txt") + (lambda (port) + (format port "~a" (current-time))))) + ;; Using the current working directory as GOPATH makes it easier for packagers ;; who need to manipulate the unpacked source code. (setenv "GOPATH" (getcwd)) @@ -152,8 +172,10 @@ dependencies, so it should be self-contained." ;; Make sure we're building for the correct architecture and OS targets ;; that Guix targets. - (setenv "GOARCH" goarch) - (setenv "GOOS" goos) + (setenv "GOARCH" (or goarch + (getenv "GOHOSTARCH"))) + (setenv "GOOS" (or goos + (getenv "GOHOSTOS"))) (match goarch ("arm" (setenv "GOARM" "7")) |