Commit graph

163 commits

Author SHA1 Message Date
adisbladis
40d32f82fc
Merge pull request #65 from adisbladis/minor-builder-refactor
Minor builder refactor
2022-06-15 06:21:49 +08:00
adisbladis
0ea20c514a refactor: inherit lib/builtins in top level scope in builder 2022-06-15 06:14:59 +08:00
adisbladis
85eaf382e6 refactor: Move replace commands computation to mkVendorEnv
It should be shared between shell envs and packages.
2022-06-15 06:14:59 +08:00
adisbladis
197bc13f6a
Merge pull request #64 from adisbladis/1.0.0-rc1
Set version to 1.0.0-rc1
2022-06-14 21:03:15 +08:00
adisbladis
6b1386b0ba Set version to 1.0.0-rc1 2022-06-14 20:58:13 +08:00
adisbladis
0a790b6075
Merge pull request #63 from adisbladis/let-package-remove
buildGoApplication: Remove package from let binding
2022-06-14 20:51:16 +08:00
adisbladis
74a2950c64 buildGoApplication: Remove package from let binding
It's the thing we return so no point in binding it to a temporary variable.
2022-06-14 19:27:24 +08:00
adisbladis
896c05d90b
Merge pull request #62 from adisbladis/nixpkgs-buildgomodule-ports-2022-06-14
Port changes to buildGoModule from nixpkgs
2022-06-14 19:19:58 +08:00
adisbladis
5a8afd711e builder: Reformat with nixpkgs-fmt
After porting builder changes from nixpkgs the structure has changed somewhat.
2022-06-14 19:14:19 +08:00
adisbladis
2028c2f3ff 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.

This is a port of ddcc7c67d2
2022-06-14 19:14:19 +08:00
adisbladis
df791b8057 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\)

This is a port of 60543c4f9e
2022-06-14 19:14:19 +08:00
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