* Go build system - build from local directory fails
@ 2024-12-18 11:01 Marc
2024-12-22 6:12 ` Marek Paśnikowski
0 siblings, 1 reply; 2+ messages in thread
From: Marc @ 2024-12-18 11:01 UTC (permalink / raw)
To: help-guix
Hey,
I'm trying to build a go program that is located locally, and figured
I'd use to go-build-system to do so. I've created the following
(use-modules (guix gexp)
(guix packages)
(gnu packages gcc)
(gnu packages golang)
(guix build-system go)
(guix git-download)
(guix utils)
(guix download)
(guix build-system go)
(gnu packages bash))
(define (vcs-file? file stat)
"Return #t if file is a version-controlled file."
(case (stat:type stat)
((directory)
(member (basename file) '(".bzr" ".git" ".hg" ".svn" "CVS")))
((regular)
;; Git sub-modules have a '.git' file that is a regular text file.
(string=? (basename file) ".git"))
(else
#f)))
(define %script-name "my-project")
(package
(name %script-name)
(version "0.1")
(source (local-file "." %script-name
#:recursive? #t
#:select? vcs-file?))
(build-system go-build-system)
(home-page #f)
(synopsis "")
(description "")
(license #f))
Which I attempted to invoke with ~guix build -f myfile.scm~ but I get
errors. The program builds without issue otherwise, but here I get the error:
command "go" "install" "-v" "-x" "-ldflags=-s -w" "-trimpath" "" failed with status 1
An initial suspicion is that I haven't set ‘#:import-path’ as expected
in the documentation. However, all examples I can find of this are
builds from a github repository rather than a local file, so I am not
sure what it needs to be set to.
Any clue what I could be missing?
Cheers,
--
Marc
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Go build system - build from local directory fails
2024-12-18 11:01 Go build system - build from local directory fails Marc
@ 2024-12-22 6:12 ` Marek Paśnikowski
0 siblings, 0 replies; 2+ messages in thread
From: Marek Paśnikowski @ 2024-12-22 6:12 UTC (permalink / raw)
To: help-guix
> An initial suspicion is that I haven't set ‘#:import-path’ as expected
> in the documentation. However, all examples I can find of this are
> builds from a github repository rather than a local file, so I am not
> sure what it needs to be set to.
>
> Any clue what I could be missing?
This is exactly it. You always must supply the #:import-path in Go build
system.
This path is vital to the operation of the build system, as it adapts Go build
environment to Guix environment. This path matches the name of the currently
built module.
In practice, it is the string that follows the 'module' keyword in go.mod
files.
I do not know the theory behind this coupling.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-12-22 6:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-18 11:01 Go build system - build from local directory fails Marc
2024-12-22 6:12 ` Marek Paśnikowski
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.