File tree 3 files changed +62
-0
lines changed
3 files changed +62
-0
lines changed Original file line number Diff line number Diff line change 33
33
default = pkgs . mkShell {
34
34
# The Nix packages provided in the environment
35
35
packages = with pkgs ; [
36
+ # Local Go package
37
+ ( import ./nix/go.nix { inherit pkgs ; } )
38
+
36
39
# Monitoring tools
37
40
promtail # Loki log shipper
38
41
prometheus # Metrics collector
49
52
# macOS-specific frameworks
50
53
darwin . apple_sdk . frameworks . Security
51
54
] ;
55
+
56
+ shellHook = ''
57
+ # Ensure golang bin is in the path
58
+ GOBIN="$(go env GOPATH)/bin"
59
+ if [[ ":$PATH:" != *":$GOBIN:"* ]]; then
60
+ export PATH="$GOBIN:$PATH"
61
+ fi
62
+ '' ;
52
63
} ;
53
64
} ) ;
54
65
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ module github.com/ava-labs/avalanchego
3
3
// - Changes to the minimum golang version must also be replicated in:
4
4
// - CONTRIBUTING.md
5
5
// - README.md
6
+ // - nix/go.nix (update version and sha256 for supported arches)
6
7
// - go.mod (here)
7
8
//
8
9
// - If updating between minor versions (e.g. 1.23.x -> 1.24.x):
Original file line number Diff line number Diff line change
1
+ { pkgs } :
2
+ let
3
+ # Helper functions to derive Go arch from Nix arch
4
+ nixArchToGoArch = arch : {
5
+ "x86_64" = "amd64" ;
6
+ "aarch64" = "arm64" ;
7
+ } . ${ arch } or arch ;
8
+
9
+ # Split system into arch and os
10
+ parseSystem = system :
11
+ let
12
+ parts = builtins . split "-" system ;
13
+ arch = builtins . elemAt parts 0 ;
14
+ os = builtins . elemAt parts 2 ;
15
+ in {
16
+ goarch = nixArchToGoArch arch ;
17
+ goos = os ;
18
+ goURLPath = "${ os } -${ nixArchToGoArch arch } " ;
19
+ } ;
20
+
21
+ # Update the following to change the version:
22
+ goVersion = "1.23.6" ;
23
+ goSHA256s = {
24
+ "linux-amd64" = "9379441ea310de000f33a4dc767bd966e72ab2826270e038e78b2c53c2e7802d" ;
25
+ "linux-arm64" = "561c780e8f4a8955d32bf72e46af0b5ee5e0debe1e4633df9a03781878219202" ;
26
+ "darwin-amd64" = "782da50ce8ec5e98fac2cd3cdc6a1d7130d093294fc310038f651444232a3fb0" ;
27
+ "darwin-arm64" = "5cae2450a1708aeb0333237a155640d5562abaf195defebc4306054565536221" ;
28
+ } ;
29
+
30
+ targetSystem = parseSystem pkgs . system ;
31
+ in
32
+ pkgs . stdenv . mkDerivation {
33
+ name = "go-${ goVersion } " ;
34
+ version = goVersion ;
35
+
36
+ inherit ( targetSystem ) goos goarch ;
37
+ GOOS = targetSystem . goos ;
38
+ GOARCH = targetSystem . goarch ;
39
+
40
+ src = pkgs . fetchurl {
41
+ url = "https://go.dev/dl/go${ goVersion } .${ targetSystem . goURLPath } .tar.gz" ;
42
+ sha256 = goSHA256s . ${ targetSystem . goURLPath } or ( throw "Unsupported system: ${ pkgs . system } " ) ;
43
+ } ;
44
+
45
+ installPhase = ''
46
+ mkdir -p $out
47
+ cp -r ./* $out/
48
+ chmod +x $out/bin/go
49
+ '' ;
50
+ }
You can’t perform that action at this time.
0 commit comments