Commit Graph

116 Commits

Author SHA1 Message Date
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 26117ed4b7
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
Bas van Dijk
8d6fbef92a buildGoModule: support overriding the go-modules derivation 2019-07-28 13:28:27 +02:00
Wael Nasreddine
1474220823
buildGoModule: add ./ to all sub-packages (#63936)
When $subPackages has more than one item, the build was failing because
./ was added only to the first subPackage. This commit adds ./ to all
specified subPackages.
2019-06-29 22:22:02 -07:00
John Children
8698c2a7d5 buildGoModule: pre-initialize module cache (#61967)
For some Go projects a go.mod file is included but there are no listed
dependencies. When this is encountered the Go toolchain will not create
a cache folder for downloaded dependencies which causes buildGoModule to
fail.

An example of a project like this that is widely used is:
https://github.com/golang/protobuf

This commit adds a mkdir command to ensure that the directory always
exists so it can be copied and prevent the failure.
2019-05-24 09:10:35 -07:00
Wael Nasreddine
6d7d69ff3e
buildGoModule: remove SSL env vars in favor of cacert in buildInputs (#58071)
cacert already exposes NIX_SSL_CERT_FILE in its setupHook. Fetchers and builders are already setup to use this variable and there's no need to export them manually.
2019-03-21 14:44:03 -07:00
Vladyslav M
832eb2559d buildGoModule: Allow pname attribute (#57787) 2019-03-17 09:29:20 -07:00
Wael M. Nasreddine
28435e47b1
buildGoModule: function for packaging Go modules
The function buildGoModule builds Go programs managed with Go modules. It builds
a Go module through a two phase build:

- An intermediate fetcher derivation. This derivation will be used to
  fetch all of the dependencies of the Go module.
- A final derivation will use the output of the intermediate derivation
  to build the binaries and produce the final output.
2019-03-14 10:31:02 -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
Andrew Dunham
274afc4932 go: build each package single-threaded (#53390)
I noticed that I was seeing the Go compiler build things in parallel even when I'd set `-j1 --cores 1`. It appears that the compiler, by default, uses the number of CPUs that are available to perform a build, while nixpkgs parallelizes at the directory level.

In order to change the fewest assumptions, this explicitly tells the Go compiler to run single-threaded. The flag's documentation is:

```
-p n
	the number of programs, such as build commands or
	test binaries, that can be run in parallel.
	The default is the number of CPUs available.
```

So this should function as expected. Feedback appreciated!
2019-02-07 14:39:53 +00:00
Jörg Thalheim
b4593b4629
buildGoPackage: also support pname
Following python-modules and stdenv.mkDerivation.
Hopefully zero rebuilds.

Motivation: https://github.com/NixOS/nixpkgs/pull/52409
2018-12-18 03:57:54 +01:00
Jörg Thalheim
79b9462468
go_1_11: fix cross compilation 2018-11-24 10:36:57 +00:00
Jörg Thalheim
9564927888
buildGoPackage: remove build-time dependency on parallel (and perl)
xargs is as good as parallel for our job

fixes #50752
2018-11-21 17:45:44 +00:00
Jörg Thalheim
9bbfc6f6e2
buildGoPackage: re-enable GOCACHE
If projects uses go1.11 modules GOCACHE is required.
Also if buildGoPackage is used in a nix-shell setting we don't
want to override GOCACHE to allow incremental builds.
This should be backported to 18.09
2018-10-28 13:51:16 +00:00
Armando Ramirez
7d238e6da8 Allow doCheck config of buildGoPackage 2018-09-10 23:05:23 +00:00
Frederik Rietdijk
f59e6f4037 Merge master into staging 2018-07-26 16:18:53 +02:00