Skip to content

Commit d515ae7

Browse files
committed
go: update to go1.18 and add overlay for golangci-lint
The update to 1.18 broke hugo and golangci-lint. I wasn't really using hugo, so I'm just commenting it out for now. To fix golangci-lint, add an overlay which builds it with 1.17. See: * NixOS/nixpkgs#168984 * golang/go#49616
1 parent 0ba73dc commit d515ae7

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

nixpkgs/home.nix

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22

33
let
44
# set channel channel to nixpkgs-unstable
5-
pkgs = import <nixpkgs> { };
5+
pkgs = import <nixpkgs> {
6+
overlays = [
7+
# https://github.com/NixOS/nixpkgs/issues/168984
8+
(self: super: {
9+
golangci-lint = super.golangci-lint.override {
10+
buildGoModule = super.buildGoModule;
11+
};
12+
})
13+
];
14+
};
615
contrast-detect-secrets = pkgs.python3Packages.callPackage ./detect-secrets.nix { };
716
# https://github.com/nix-community/neovim-nightly-overlay
817
in
@@ -23,23 +32,31 @@ in
2332
# changes in each release.
2433
home.stateVersion = "20.03";
2534

26-
# fsync on darwin is broken in that it's not a true fsync, so go's
27-
# syscall wrapper calls F_FULLFSYNC instead to make sure that writes are
28-
# actually flushed as expected. In general, with a laptop, there's probably
29-
# no issue, because the battery controler should handle flushing cache when
30-
# there's a sudden power loss or something. Down the rabbit hole of tweets is
31-
# more justification on this. This patch changes it to just call fsync. I
32-
# never use darwin besides on a laptop, so it should be safe enough for me.
33-
#
34-
# https://github.com/golang/go/issues/28739
3535
nixpkgs.overlays = [
36+
# (import (builtins.fetchTarball {
37+
# url = https://github.com/nix-community/neovim-nightly-overlay/archive/master.tar.gz;
38+
# }))
3639
(self: super: {
37-
go = super.go.overrideAttrs (old: {
40+
# fsync on darwin is broken in that it's not a true fsync, so go's
41+
# syscall wrapper calls F_FULLFSYNC instead to make sure that writes are
42+
# actually flushed as expected. In general, with a laptop, there's probably
43+
# no issue, because the battery controler should handle flushing cache when
44+
# there's a sudden power loss or something. Down the rabbit hole of tweets is
45+
# more justification on this. This patch changes it to just call fsync. I
46+
# never use darwin besides on a laptop, so it should be safe enough for me.
47+
#
48+
# https://github.com/golang/go/issues/28739
49+
go_1_18 = super.go_1_18.overrideAttrs (old: {
3850
patches = (old.patches or [ ]) ++ (
3951
if lib.stdenv.isDarwin then [ ./fd_fsync_darwin.patch ]
4052
else [ ]
4153
);
4254
});
55+
56+
# https://github.com/NixOS/nixpkgs/issues/168984
57+
golangci-lint = super.golangci-lint.override {
58+
buildGoModule = super.buildGoModule;
59+
};
4360
})
4461
];
4562

@@ -56,7 +73,7 @@ in
5673
graphviz
5774
jq
5875
tokei
59-
hugo
76+
# hugo
6077
age
6178
silver-searcher
6279
zlib
@@ -87,7 +104,7 @@ in
87104
# nix language server
88105
# rnix-lsp
89106

90-
golangci-lint
107+
golangci-lint
91108

92109
contrast-detect-secrets
93110
];
@@ -110,7 +127,7 @@ in
110127

111128
programs.go = {
112129
enable = true;
113-
package = pkgs.go;
130+
package = pkgs.go_1_18;
114131
goPath = "${builtins.getEnv "HOME"}/gopath";
115132
goBin = "${builtins.getEnv "HOME"}/gobin";
116133
};

0 commit comments

Comments
 (0)