Skip to content

Commit f55e704

Browse files
committed
Remove gomod2nix and update Go build configuration
Signed-off-by: Martin Baillie <[email protected]>
1 parent 1c11fa8 commit f55e704

File tree

4 files changed

+9
-352
lines changed

4 files changed

+9
-352
lines changed

.goreleaser.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
report_sizes: false
22

33
builds:
4-
- goos:
4+
- env:
5+
- CGO_ENABLED=0
6+
goos:
57
- darwin
68
- windows
79
- linux

flake.lock

Lines changed: 0 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
inputs.nixpkgs.follows = "nixpkgs";
1111
};
1212

13-
gomod2nix = {
14-
url = "github:nix-community/gomod2nix";
15-
inputs.nixpkgs.follows = "nixpkgs";
16-
};
17-
1813
gitignore = {
1914
url = "github:hercules-ci/gitignore.nix";
2015
inputs.nixpkgs.follows = "nixpkgs";
@@ -27,7 +22,6 @@
2722
nixpkgs,
2823
flake-parts,
2924
devshell,
30-
gomod2nix,
3125
gitignore,
3226
...
3327
}:
@@ -52,33 +46,27 @@
5246
rev = self.rev or "dirty";
5347
ver = if self ? "dirtyRev" then self.dirtyShortRev else self.shortRev;
5448
date = self.lastModifiedDate or "19700101";
55-
go = pkgs.go_1_22;
5649
in
5750
{
5851
_module.args.pkgs = import nixpkgs {
5952
inherit system;
6053
config.allowUnfree = true; # BSL2... Hashicorp...
6154
overlays = [
6255
devshell.overlays.default
63-
gomod2nix.overlays.default
6456
];
6557
};
6658

67-
packages.default = gomod2nix.legacyPackages.${system}.buildGoApplication {
68-
inherit name go;
59+
packages.default = pkgs.buildGo123Module {
60+
inherit name;
6961
src = gitignore.lib.gitignoreSource ./.;
70-
# Must be added due to bug:
71-
# https://github.com/nix-community/gomod2nix/issues/120
72-
pwd = ./.;
73-
modules = ./gomod2nix.toml;
62+
env.CGO_ENABLED = 0;
63+
vendorHash = "sha256-hscwOZhaVL17HPUGfs8uYSQt80D4HK4W6kNdkSmsQdA=";
7464
flags = [ "-trimpath" ];
75-
# CGO_ENABLED = 0;
7665
ldflags = [
7766
"-s"
7867
"-w"
7968
"-extld ld"
80-
"-extldflags"
81-
"-static"
69+
"-extldflags -static"
8270
"-X ${package}/github.projectName=${name}"
8371
"-X ${package}/github.projectDocs=https://${package}"
8472
"-X github.com/prometheus/common/version.BuildDate=${date}"
@@ -88,7 +76,6 @@
8876
"-X github.com/prometheus/common/version.Branch=main"
8977
"-X github.com/prometheus/common/version.BuildUser=nix"
9078
];
91-
doCheck = false;
9279
};
9380

9481
devShells.default = pkgs.devshell.mkShell rec {
@@ -112,7 +99,6 @@
11299
gnugrep
113100
go
114101
golangci-lint
115-
gomod2nix.legacyPackages.${system}.gomod2nix
116102
goreleaser
117103
syft
118104
vault-bin
@@ -161,7 +147,7 @@
161147
prjRoot
162148
+ ''
163149
echo >&2 "==> Tidying modules"
164-
go mod tidy && gomod2nix
150+
go mod tidy
165151
'';
166152
help = "clean transient files";
167153
}

0 commit comments

Comments
 (0)