Commit Graph

174 Commits

Author SHA1 Message Date
Sandro Jäckel
20e17c8cd4
buildGoModules: don't add kalbasit as maintainer to every go package 2022-07-20 18:28:36 +02:00
Jörg Thalheim
4f8a04f180
Merge pull request #173702 from bdd/go-checkFlags
go-modules/packages: Run unit tests under subdirs
2022-06-28 08:30:43 +02:00
Nick Cao
e4515da3c2 buildGoModule: passing CGO_ENABLED explicitly 2022-06-20 15:58:05 +10:00
zowoq
b246d54635 buildGoModule: remove runVend
follow up from 8a8c88de70bd7f967cb20ad07583ea9ef12a4a94
2022-06-08 19:40:31 +10:00
Berk D. Demir
89864413b2 go-modules/packages: Run unit tests under subdirs
Bug:
Due to the way `buildGoDir` function was repurposed to also run `go
test`, if `checkFlags` was defined, `go test` was ran only at the top
level directory. Only the first element of `checkFlags` array would get
passed to the `go test` command as arguments.

Fix:
Now the first parameter to `buildGoDir` is handled as the command.  If
the command is "test" `checkFlags` get passed as arguments along with
other build flags like ldflags, tags, etc.

Readability:
- Iteratively build a flag array in `buildGoDir` instead of single long
  variable expansion command line.
- Bash style: Single line local assignment of positional parameters.
2022-06-01 00:52:20 +00:00
Vladimír Čunát
e11568dd9c
Revert "Merge #171177: go-modules/packages: Improve checkFlags handling"
This reverts commit 361139c574ab2a37c46cd705fac90ada130ea139, reversing
changes made to 77ee91f1d318a03fa96571656ce8af25a236fbca.

This broke tests in some go packages, and at this point I don't want
further delays from figuring out what's wrong.  This probably won't
make it to 22.05.  Example failures:
  https://hydra.nixos.org/build/176551928
  https://hydra.nixos.org/build/176546993
but I think there were more among
  https://hydra.nixos.org/eval/1762178?compare=1762151#tabs-now-fail
2022-05-17 11:50:29 +02:00
github-actions[bot]
a44988ac0d
Merge master into staging-next 2022-05-15 06:01:17 +00:00
linsui
6e19bfd952 buildGoModule: allow goproxy 2022-05-15 11:57:44 +08:00
Berk D. Demir
99786f9a57 go-modules/packages: Improve checkFlags handling
- Fix handling of `checkFlags` derivation attribute when it's a list of
  two or more elements.

- Improve the readability go `buildGoDir` function with flag array
  building and "test" command conditional.

- Bash style: Single line local assignment of positional parameters.
2022-05-02 14:35:07 +00:00
Manuel Mendez
ddcc7c67d2 go: Apply package exclusion equally
The exclusion logic was moved out of getGoDirs but only buildPhase was updated
causing checkPhase to possibly fail. This happened in golint as it has go
files in testdata that are meant as testdata files and not go packages to
test which caused the checkPhase to fail.

Fixes #167717
2022-04-09 09:57:35 +10:00
Manuel Mendez
60543c4f9e go: Drop unnecessary backslash-escape
There's no backslash interpretation going on within single-quote strings
which means there's no need to escape the backslash. Since this was going
on within single-quote strings the $exclude variable ended up having 2
backslashes (`\\`) instead of the intended single backslash. This meant
that the regex that was built up was incorrect. For example prometheus'
exclude contents before and after this change are:

✕: \(/_\|examples\|Godeps\|testdata\\|documentation/prometheus-mixin\)
✓: \(/_\|examples\|Godeps\|testdata\|documentation/prometheus-mixin\)
2022-04-04 13:37:08 +10:00
zowoq
b6aa99a8d2 buildGoModule: fix vendor conditional, set GOPROXY unconditionally
with sandboxing disabled this could still access the network
2022-03-17 21:24:58 +10:00
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
fe00d45c50 buildGoModule: remove runVend
follow up from 8a8c88de70bd7f967cb20ad07583ea9ef12a4a94
2022-01-08 10:38:32 +10:00
zowoq
8a8c88de70 buildGoModule: use proxyVendor instead of runVend 2022-01-06 14:00:58 +10:00
Julien Moutinho
378fe3e07f go: fix buildGoModule by passing patchFlags to go-modules too 2021-12-28 22:18:17 -05:00
zowoq
3360a376cb buildGoModule: warn if buildFlagsArray is used 2021-08-26 21:35:06 +10:00
zowoq
cb7d80dcaf buildGo{Module,Package}: warn if buildFlags is used 2021-08-23 06:41:14 +10:00
zowoq
a4461b97c6 buildGoModule: add proxyVendor 2021-08-06 09:10:09 +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
Ben Siraphob
eae7e30588
Merge pull request #129286 from helsinki-systems/feat/buildGoMod-checkFlags 2021-07-06 01:49:04 +07:00
ajs124
dc973241a9 buildGoModule: add support for checkFlags 2021-07-05 02:47:32 +02:00
zowoq
214ee12cef buildGoModule: fix enableParallelBuilding
enableParallelBuilding is unset so NIX_BUILD_CORES is always 1.

This copies how enableParallelBuilding is set in buildGoPackage.
2021-07-04 14:35:50 +10: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
zowoq
bb419e051d
buildGoModule: use assert for checking goPackagePath (#113046)
also remove a `disabled` leftover from 26117ed4b78020252e49fe75f562378063471f71
2021-02-15 09:53:04 -08: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
Florian Klink
3c8981ee8b buildGoModule: fix cross-compilation with CGO_ENABLED=1
When building a go binary that's linking against some .so/.a, while
cross-compiling, we need to pass the correct compiler, otherwise
`go build` will fail with the not-so helpful error message:

```
gcc_arm64.S: Assembler messages:
gcc_arm64.S:28: Error: no such instruction: `stp x29,x30,[sp,'
gcc_arm64.S:32: Error: too many memory references for `mov'
gcc_arm64.S:34: Error: no such instruction: `stp x19,x20,[sp,'
gcc_arm64.S:37: Error: no such instruction: `stp x21,x22,[sp,'
gcc_arm64.S:40: Error: no such instruction: `stp x23,x24,[sp,'
gcc_arm64.S:43: Error: no such instruction: `stp x25,x26,[sp,'
gcc_arm64.S:46: Error: no such instruction: `stp x27,x28,[sp,'
gcc_arm64.S:50: Error: too many memory references for `mov'
gcc_arm64.S:51: Error: too many memory references for `mov'
gcc_arm64.S:52: Error: too many memory references for `mov'
gcc_arm64.S:54: Error: no such instruction: `blr x20'
gcc_arm64.S:55: Error: no such instruction: `blr x19'
gcc_arm64.S:57: Error: no such instruction: `ldp x27,x28,[sp,'
gcc_arm64.S:60: Error: no such instruction: `ldp x25,x26,[sp,'
gcc_arm64.S:63: Error: no such instruction: `ldp x23,x24,[sp,'
gcc_arm64.S:66: Error: no such instruction: `ldp x21,x22,[sp,'
gcc_arm64.S:69: Error: no such instruction: `ldp x19,x20,[sp,'
gcc_arm64.S:72: Error: no such instruction: `ldp x29,x30,[sp],'
```
2020-12-26 23:40:05 +01:00
zowoq
863706ef30 buildGoModule: disallow goPackagePath
This is unnecessary with `buildGoModule`, it's usually cruft from `buildGoPackage` conversions.
2020-12-17 16:38:13 +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
66d424514f buildGoModule: copy vendor instead of symlinking
Allow the second phase to modify the contents of the vendor directory.
2020-11-06 13:55:46 +10:00
zowoq
092aa94ca7 buildGoModule: use optionalString 2020-10-28 09:06:55 +10:00
Malte Brandy
cebf9198f3
treewide: De-inline uses of lib.boolToString
This commit should not change eval results
2020-10-14 01:46:17 +02: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
zowoq
92a2c31d79 buildGoModule: remove modSha256 2020-08-20 08:02:36 +10:00
zowoq
cdd4547867 buildGoModule: check if vendor exists with deleteVendor 2020-08-14 07:50:37 +10:00
zowoq
961aa31455 buildGoModule: update deleteVendor docs 2020-08-14 07:50:37 +10:00
zowoq
cc06d7a26f buildGoModule: change doCheck default to true 2020-08-10 16:01:03 +10:00
Colin L Rice
95be7b25be go-modules: Add useVend flag to go-modules 2020-07-28 21:11:28 -04:00
zowoq
0f19b9ba72
Revert "Group packages by language/builder via dummy maintainer" 2020-07-18 17:45:08 +10:00
zowoq
60d878317b buildGoModule: add nixpkgs-go maintainer 2020-07-17 11:16:54 +10:00
zowoq
87dbe6d797 buildGoModule: remove trailing whitespace 2020-06-28 11:32:21 +10:00
zowoq
a2e6ff2cce buildGoModule: require vendorSha256 to be set in packages 2020-06-17 11:07:00 +10:00
Colin L Rice
a0ddea1d6a
go-modules: Add in old modsha256 w/ warning 2020-05-14 07:21:52 +01:00
Colin L Rice
9761128d2d
go-modules: Augment builds w/ vendor src
This is done in response to complaints that the module format is not
human readable. The vendor source blob is flat files and should be
extremely readable.
2020-05-14 07:21:49 +01:00
Jörg Thalheim
060a9227c2
buildGoModule: enable strictDeps
This will improve cross compiling in the long run.
See also https://github.com/NixOS/nixpkgs/pull/82786
2020-03-18 11:29:29 +00:00
Benjamin Hipple
5f77ff6384
buildGoModule: passthru the modSha256 (#82027)
The builder does not technically need the modSha256 of the vendor dir, and even
though we pass it the entire vendor dir it makes sense not to risk having an
accidental dependency on that variable.

However, tools like [nixpkgs-update](https://github.com/ryantm/nixpkgs-update)
need to inspect the `modSha256` of a package in order to be able to update them,
and since this is a real part of the package (describes info about its
dependencies) let's add it to `passthru`.

Specifically, this allows us to run a cmd like `nix eval -f . tflint.modSha256`
to get the current value, which is how the bot finds it to replace with the new
version in the Rust ecosystem.
2020-03-11 09:52:07 +00:00
zimbatm
f373ecec8f buildGoModule: support impure modules (#76532)
When modSha256 is null, disable the nix sandbox instead of using a
fixed-output derivation. This requires the nix-daemon to have
`sandbox = relaxed` set in their config to work properly.

Because the output is (hopefully) deterministic based on the inputs,
this should give a reproducible output. This is useful for development
outside of nixpkgs where re-generating the modSha256 on each mod.sum
changes is cumbersome.

Don't use this in nixpkgs! This is why null is not the default value.
2019-12-28 12:36:42 -08:00
Danylo Hlynskyi
debca548f9
dolt: init at 0.12.0 (#75693)
* dolt: init at 0.12.0

* Update pkgs/servers/sql/dolt/default.nix

Co-Authored-By: robert seaton <robbpseaton@gmail.com>

* fix eval

* Update pkgs/servers/sql/dolt/default.nix

Co-Authored-By: Wael Nasreddine <wael.nasreddine@gmail.com>

* update Go docs as well
2019-12-16 00:58:16 +02:00
Mario Rodas
c5733e7a09
buildGoModule: disable consult the checksum database on build
Since Go 1.13, `GOSUMDB` defaults to "sum.golang.org", to consult the
checksum database of the main module's go.sum.

We already use the default behavior when building `go-modules`, but Go
tries to consult the checksum database again when building the module,
and fails because since it requires `cacert` and `git` which are not
propagated when building the package.
2019-12-01 16:20:00 -05:00
Mario Rodas
589d4ff232
buildGoModule: remove cached lookup results and tiles
Since GO 1.13, the go command caches the lookup results and tiles in
$GOPATH[1], hence making the module directory non-deterministic.

Use the `-f` flag when removing /sumdb, for compatibility with Go 1.12
because in that version does not exists that directory.

[1] https://go.googlesource.com/proposal/+/master/design/25530-sumdb.md#command-client
2019-10-12 12:00:00 -05:00