Commit Graph

21 Commits

Author SHA1 Message Date
Manuel Mendez
8b5a7940b0 go: Bunch of fixes when using excludedPackages and other bits
Few things going on in this commit:

Do not print "Building subPakage $pkg" message if actually going to skip the
package. This was confusing to me when I was trying to figure out how to set
excludedPackages and seeing the "Building subpackage $pkg" messages for
packages I wanted to skip. Turns out this messages was being printed before
checking if we actually wanted to build the package and not necessarily that my
excludedPackages was wrong.

Make go-packages look a little bit more like go-modules, by adding testdata to
the default list of excluded packages.

This commit also does some setup outside the buildGoDir function so that we
avoid checking `excludedPackages` for every package and cut down the number
of grep calls by half since we always want at least one grep for the default
excludedPackages, might as well just add to the patterns being checked.

Finally, adds documentation for usage of excludedPackages and subPackages. I
had to read the implementation to figure out how to correctly use these
function arguments since there was no documentation and different uses in the
code base. So this commit documents usage of the arguments.
2022-03-04 13:32:44 +10:00
zowoq
3c2d7dbfdf buildGoPackage: warn if buildFlagsArray is used 2021-08-26 15:43:28 +10:00
zowoq
cb7d80dcaf buildGo{Module,Package}: warn if buildFlags is used 2021-08-23 06:41:14 +10:00
zowoq
b60dde0c1e buildGo{Module,Package}: add tags argument
Simpler method of setting tags rather than using some combination of buildFlags, buildFlagsArray, preBuild, etc

Using `lib.concatStringsSep ","` as space separated tags are deprecated in go.
2021-08-06 09:09:58 +10:00
ajs124
3f29b579b0 buildGoPackage: add support for checkFlags 2021-07-05 02:58:21 +02:00
Silvan Mosberger
155ae682a5 buildGoModule/buildGoPackage: Introduce ldflags argument
Previously it was not possible to define multiple ldflags, since only
the last definition applies, and there's some quoting issues with
`buildFlagsArray`. With the new `ldflags` argument it's possible to do
this, e.g.

    ldflags = drv.ldflags or [] ++ [
      "-X main.Version=1.0"
    ]

can now properly append a flag without clearing all previous ldflags.
2021-06-05 09:54:36 +10:00
adisbladis
2c593e8e76
buildGoPackage: Respect passing CGO_ENABLED explicitly
This used to work but was broken by 6a27d63a88.
2021-02-24 23:22:19 +01:00
Pavol Rusnak
cf2a67fef3
pkgs/development: stdenv.lib -> lib
this takes care of the following folders in pkgs/development:
* arduino
* chez-modules
* go-packages
* guile-modules
* idris-modules
* perl-modules
* r-modules
* ruby-modules
2021-01-17 19:11:59 +01:00
zowoq
26117ed4b7 buildGo{Module,Package}: remove disabled
This doesn't seem to have been used since pkgs/top-level/go-packages.nix was split up.
2021-01-11 06:00:38 +10:00
zowoq
4e9f7bbf85 buildGo{Package,Module}: set trimpath in GOFLAGS
Also drop removeReferencesTo

`-trimpath` removes all file system paths from the compiled executable,
this should improve reproducibility.
2020-11-18 08:13:34 +10:00
zowoq
23c781a810 buildGoPackage: check/delete vendor 2020-09-08 16:32:39 +10:00
Jörg Thalheim
eab48f5a1b
buildGo{module,package}: also fixup $out/{libexec,lib}
also suppresses errors if those directories are not present
2020-08-28 13:19:11 +01:00
betaboon
b9ac86e752 buildGoPackage: remove references in $out/libexec 2020-07-03 09:21:26 +02:00
zowoq
3f17518490 buildGoPackage: use $out instead of $bin 2020-04-28 20:30:23 +10:00
zowoq
c1facd193e buildGoPackage: remove inactive maintainer 2020-04-26 12:42:58 +10:00
Jörg Thalheim
ff2ea911b3
buildGoPackage: enable strictDeps
In order to improve cross-compilation let's enable strictDeps
and fix what breaks.
2020-03-28 11:46:38 +00:00
Emery Hemingway
0bec813abf buildGoPackage: remove ehmry from maintainers
I no longer write Go and have lost familiarity with the tooling.
2020-03-16 10:14:04 +05:30
Mario Rodas
46abdee40b buildGoPackage: disable module-mode
Go 1.13 slightly changed the behavior GO111MODULE=auto [1], which might
accidentally cause the go command to build the module, for instance in
the checkPhase:

    [GO111MODULE=auto] activates the module-aware mode of the go command
    whenever the current working directory contains, or is below a
    directory containing, a go.mod file — even if the current directory
    is within GOPATH/src.

[1] https://golang.org/doc/go1.13#proxy-vars
2019-12-10 18:50:44 +01:00
Ding Xiang Fei
6a27d63a88 buildGoPackage: enable cross compilation 2019-06-25 14:42:12 +08:00
Matthew Bauer
1f46aaab1b buildGoPackage: keep string context (#63680)
In Nix, each string has a context that it carries of where it
originated. Some functions like filterAttrs modify the context of its
args when doing comparisons. That is important because we use the
string context of “name” to get where a derivation was defined. This
causes some builtins like unsafeGetAttrPos to report incorrectly that
the string was set in lib/attrsets.nix and reporting that as the
source file. Using removeAttrs avoids this problem.

Fixes #63679
2019-06-22 19:07:26 -07:00
Wael M. Nasreddine
a0d835e95d
buildGoPackage: move it under a different path
This change moves buildGoPackage from pkgs/development/go-modules to
pkgs/development/go-packages, so we can have buildGoModule at
pkgs/development/go-modules.
2019-03-13 18:40:24 -07:00