Commit graph

152 commits

Author SHA1 Message Date
adisbladis
31102e0753 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.

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.

This is a port of 8b5a7940b0
2022-06-14 19:14:19 +08:00
adisbladis
359449a284 buildGoApplication: warn if buildFlagsArray is used
This is a port of 3360a376cb
2022-06-14 19:14:19 +08:00
adisbladis
8aa44afb7e buildGoApplication: warn if buildFlags is used
This is a port of cb7d80dcaf
2022-06-14 19:14:19 +08:00
adisbladis
f42a0cddb4 buildGoApplication: 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.

This is a port of b60dde0c1e
2022-06-14 19:14:19 +08:00
adisbladis
5913cf95d5 buildGoApplication: add support for checkFlags
This is a port of dc973241a9
2022-06-14 19:14:19 +08:00
adisbladis
24c5e41124 buildGoApplication: 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.

This is a port of 155ae682a5
2022-06-14 19:14:19 +08:00
adisbladis
c5da508f3c
Merge pull request #61 from adisbladis/nix-reference-docs
Add Nix reference docs
2022-06-14 18:31:10 +08:00
adisbladis
ff1f766e83 README: Add link to Nix reference docs 2022-06-14 18:26:50 +08:00
adisbladis
e3745a9b6f docs: Add Nix API reference docs 2022-06-14 18:26:50 +08:00
adisbladis
366c0e5a17 mkGoEnv: Pass attrs on to mkDerivation 2022-06-14 18:26:50 +08:00
adisbladis
aa90002013
Merge pull request #60 from adisbladis/getting-started-docs
Add getting started docs
2022-06-14 18:07:37 +08:00
adisbladis
c6aa07b58f README: Add reference to the announcement blog post 2022-06-14 18:02:02 +08:00
adisbladis
219f2b41a1 Github actions: Bump install-nix-action 2022-06-14 17:58:17 +08:00
adisbladis
c6bc2d55a2 Add link to getting started docs in README 2022-06-14 17:55:59 +08:00
adisbladis
59869b91af Add getting started docs 2022-06-14 17:54:23 +08:00
adisbladis
759483247e Align flake template with recent API changes and improvements 2022-06-14 17:35:19 +08:00
adisbladis
6a03c9a05f
Merge pull request #59 from adisbladis/pkgs-internal
Move internal packages to internal subdirectory
2022-06-14 17:15:30 +08:00
adisbladis
86ee592eb2 Move internal packages to internal subdirectory
So they can't be imported from external repositories.

I'm not giving any stability guarantees on anything except the CLI.
2022-06-14 17:10:32 +08:00
adisbladis
9a14682b8b cmd/root.go: Clean up some dead code 2022-06-14 09:48:33 +08:00
adisbladis
85ee095f0d
Merge pull request #58 from adisbladis/behaviour-alignment
Build non-development packages in the same way as development packages
2022-06-14 08:28:07 +08:00
adisbladis
509b97c288 Build non-development packages in the same way as development packages
The difference in behaviour was unfortunate.

The only downside I can see is that this doesn't allow for mixed
origins in the same package, which probably shouldn't be done anyway.
2022-06-14 08:19:42 +08:00
adisbladis
60a67aaa2d
Merge pull request #57 from adisbladis/cross-fix
Fix cross compilation
2022-06-14 05:46:36 +08:00
adisbladis
f8646af3f2 gomod2nix: Only generate completions if we are not cross compiling 2022-06-14 05:27:43 +08:00
adisbladis
d404767bec builder: Build internal packages for host plattform 2022-06-14 05:27:43 +08:00
adisbladis
9c1bde84d3
Merge pull request #56 from adisbladis/non-dev-deps
Add package generation for non development packages
2022-06-14 05:27:15 +08:00
adisbladis
1ffea526a0 Add package generation for non development packages
This makes it possible to generate packages that you do not have a
local checkout for, e.g. running:
`gomod2nix generate --outdir example/ golang.org/x/tools/cmd/stringer`

This will be useful for packaging dependencies that you are not
developing, but just simply packaging.
2022-06-14 05:15:43 +08:00
adisbladis
116b98475f
Merge pull request #55 from adisbladis/import-sources
Add an import subcommand
2022-06-13 23:39:41 +08:00
adisbladis
7224069881 Set meta on derivation 2022-06-13 23:33:28 +08:00
adisbladis
363017e3f3 Install shell completions in derivation 2022-06-13 23:33:19 +08:00
adisbladis
ab0d607923 Add an import subcommand
That imports sources from the local Go sources into the Nix store.
2022-06-13 23:15:35 +08:00
adisbladis
2792ae6af4 Add generate subcommand
Which does the same as the previous root command.
2022-06-13 23:15:35 +08:00
adisbladis
52125f6072 Use cobra for command line parsing 2022-06-13 23:15:35 +08:00
adisbladis
96e8b390aa
Merge pull request #54 from adisbladis/cgo-enabled-go-version
Factor out Go version / no default for CGO_ENABLED
2022-06-13 20:58:46 +08:00
adisbladis
aae59a6851 Don't set CGO_ENABLED by default
Instead let the compiler decide.
This will result in less cryptic errors.
2022-06-13 20:53:45 +08:00
adisbladis
ade4c20234 Factor out Go version selection from mkGoEnv and add it to buildGoApplication too 2022-06-13 20:53:45 +08:00
adisbladis
c3c8aa564d
Merge pull request #53 from tweag/mkgoenv
Add `mkGoEnv` function
2022-06-13 20:44:29 +08:00
adisbladis
e95e393da8 tests: Add mkGoEnv test 2022-06-13 20:37:42 +08:00
adisbladis
908ab2bb87 Precompile internal packages instead of using go run
It shaves off a second or so of wait time per environment.
2022-06-13 20:37:42 +08:00
adisbladis
973b050adf fetcher: Make sure sources are writable before filtering .ds_store 2022-06-13 20:37:42 +08:00
adisbladis
1eb70073c4 Bump dependencies 2022-06-13 20:37:42 +08:00
adisbladis
a4bed25a86 Add mkGoEnv function
This creates an `mkGoEnv` function which takes care of adding the
correct Go package to your development environment and installs
development dependencies from tools.go in a Nix derivation.

The "normal" workflow around Go with tools.go just sticks development
dependencies in $GOBIN which isn't ideal since you have no separation
between projects.
2022-06-13 20:37:42 +08:00
adisbladis
71c797eb0d
Merge pull request #52 from adisbladis/mac-ds-store-filter
Filter MacOS .DS_Store directories
2022-06-01 01:51:37 +08:00
adisbladis
d7830bd5b2 Filter MacOS .DS_Store directories
Now that we're hashing files directly from the Go sources on the host
system we need to avoid these files.

Closes #49.
2022-06-01 01:46:29 +08:00
adisbladis
fb910de8cc
Merge pull request #51 from adisbladis/max-workers
Reintroduce the max workers flag
2022-05-31 02:13:57 +08:00
adisbladis
e1d46e6973 Reintroduce the max workers flag
It turns out that this is actually useful to limit the number of open files.

Fixes https://github.com/tweag/gomod2nix/issues/50.
2022-05-31 02:07:27 +08:00
adisbladis
bf3e9afe32
Merge pull request #48 from adisbladis/third-party-2022-05-30
Bump go.mod dependencies
2022-05-30 20:00:09 +08:00
adisbladis
3de2f9540e Bump go.mod dependencies 2022-05-30 19:21:48 +08:00
adisbladis
90653f16ab
Merge pull request #47 from adisbladis/flake-template
templates: Add a flake template
2022-05-30 19:21:37 +08:00
adisbladis
d30b3ca30a templates: Add a flake template 2022-05-30 19:17:02 +08:00
adisbladis
3ae35c5ce1
Merge pull request #46 from adisbladis/golangci-lint
Add golangci-lint
2022-05-30 18:49:27 +08:00