|
10 | 10 | inputs.nixpkgs.follows = "nixpkgs"; |
11 | 11 | }; |
12 | 12 |
|
13 | | - gomod2nix = { |
14 | | - url = "github:nix-community/gomod2nix"; |
15 | | - inputs.nixpkgs.follows = "nixpkgs"; |
16 | | - }; |
17 | | - |
18 | 13 | gitignore = { |
19 | 14 | url = "github:hercules-ci/gitignore.nix"; |
20 | 15 | inputs.nixpkgs.follows = "nixpkgs"; |
|
27 | 22 | nixpkgs, |
28 | 23 | flake-parts, |
29 | 24 | devshell, |
30 | | - gomod2nix, |
31 | 25 | gitignore, |
32 | 26 | ... |
33 | 27 | }: |
|
52 | 46 | rev = self.rev or "dirty"; |
53 | 47 | ver = if self ? "dirtyRev" then self.dirtyShortRev else self.shortRev; |
54 | 48 | date = self.lastModifiedDate or "19700101"; |
55 | | - go = pkgs.go_1_22; |
56 | 49 | in |
57 | 50 | { |
58 | 51 | _module.args.pkgs = import nixpkgs { |
59 | 52 | inherit system; |
60 | 53 | config.allowUnfree = true; # BSL2... Hashicorp... |
61 | 54 | overlays = [ |
62 | 55 | devshell.overlays.default |
63 | | - gomod2nix.overlays.default |
64 | 56 | ]; |
65 | 57 | }; |
66 | 58 |
|
67 | | - packages.default = gomod2nix.legacyPackages.${system}.buildGoApplication { |
68 | | - inherit name go; |
| 59 | + packages.default = pkgs.buildGo123Module { |
| 60 | + inherit name; |
69 | 61 | 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="; |
74 | 64 | flags = [ "-trimpath" ]; |
75 | | - # CGO_ENABLED = 0; |
76 | 65 | ldflags = [ |
77 | 66 | "-s" |
78 | 67 | "-w" |
79 | 68 | "-extld ld" |
80 | | - "-extldflags" |
81 | | - "-static" |
| 69 | + "-extldflags -static" |
82 | 70 | "-X ${package}/github.projectName=${name}" |
83 | 71 | "-X ${package}/github.projectDocs=https://${package}" |
84 | 72 | "-X github.com/prometheus/common/version.BuildDate=${date}" |
|
88 | 76 | "-X github.com/prometheus/common/version.Branch=main" |
89 | 77 | "-X github.com/prometheus/common/version.BuildUser=nix" |
90 | 78 | ]; |
91 | | - doCheck = false; |
92 | 79 | }; |
93 | 80 |
|
94 | 81 | devShells.default = pkgs.devshell.mkShell rec { |
|
112 | 99 | gnugrep |
113 | 100 | go |
114 | 101 | golangci-lint |
115 | | - gomod2nix.legacyPackages.${system}.gomod2nix |
116 | 102 | goreleaser |
117 | 103 | syft |
118 | 104 | vault-bin |
|
161 | 147 | prjRoot |
162 | 148 | + '' |
163 | 149 | echo >&2 "==> Tidying modules" |
164 | | - go mod tidy && gomod2nix |
| 150 | + go mod tidy |
165 | 151 | ''; |
166 | 152 | help = "clean transient files"; |
167 | 153 | } |
|
0 commit comments