From 3dba6a0fda2c7d7eed914227aa5a7e4bd3fd3b17 Mon Sep 17 00:00:00 2001 From: Mohammad Abdolirad Date: Mon, 24 Aug 2026 15:21:17 +0200 Subject: [PATCH] use stock golangci-lint from nixpkgs - drop the overlay now that unstable ships 2.13.1 - keep gofmt on the pinned go 1.27 toolchain - switch isBrokenPipe to errors.AsType and restore SA4023 --- .golangci.yaml | 4 +-- flake.lock | 6 ++-- flake.nix | 19 ++--------- internal/cmd/shell/executor.go | 4 +-- nix/checks.nix | 7 ++-- nix/golangci-lint.nix | 61 ---------------------------------- 6 files changed, 10 insertions(+), 91 deletions(-) delete mode 100644 nix/golangci-lint.nix diff --git a/.golangci.yaml b/.golangci.yaml index 2ce0167..187cb7b 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -277,9 +277,7 @@ linters: staticcheck: # Enable all checks (SA*, S*, ST*, QF*). - # SA4023: false positives on nabat Context.Form (can return nil) with the - # Go 1.27 staticcheck snapshot; re-enable when upstream settles. - checks: ["all", "-SA4023"] + checks: ["all"] nolintlint: # Fail unused //nolint and require naming the suppressed linter (no bare //nolint). diff --git a/flake.lock b/flake.lock index e01686d..e308ade 100644 --- a/flake.lock +++ b/flake.lock @@ -57,11 +57,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1787172299, - "narHash": "sha256-PShzS87awOlE5XWkxUGBd/58/F+AtE2ZMgFffKj4r8s=", + "lastModified": 1787394516, + "narHash": "sha256-pRGOQSClnXNI2iLUG6DYpsGvYcuw0drOutVZFTJNw90=", "owner": "nixos", "repo": "nixpkgs", - "rev": "07e1d92cdc0ed416cfa11ff3ca40d17e61cfba7a", + "rev": "c8f90650c15282fa8656a041bfbbd2403997a9a7", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index c0944b7..0cadaab 100644 --- a/flake.nix +++ b/flake.nix @@ -21,29 +21,14 @@ system: let pkgs = import nixpkgs { inherit system; }; - # nixpkgs' default `go` may lag; pin the toolchain Nabat requires. + # nixpkgs' default `go` is still 1.26; pin 1.27 for the module. go = pkgs.go_1_27; buildGoModule' = pkgs.buildGoModule.override { inherit go; }; deployahVendorHash = "sha256-CT9xvdQvEU6shdz12Yu30R/uvbV36oA6Nok0LZ9f2mE="; - golangci-lint = import ./nix/golangci-lint.nix { - buildGoModule = buildGoModule'; - inherit (pkgs) - fetchFromGitHub - installShellFiles - lib - stdenv - buildPackages - ; - }; - - # nixpkgs gopls is built with default `go` (still 1.26). gopls must be - # compiled with at least the toolchain it analyzes. - gopls = pkgs.gopls.override { - buildGoLatestModule = buildGoModule'; - }; + inherit (pkgs) golangci-lint gopls; deployah = import ./nix/deployah.nix { buildGoModule = buildGoModule'; diff --git a/internal/cmd/shell/executor.go b/internal/cmd/shell/executor.go index 056467c..3be621e 100644 --- a/internal/cmd/shell/executor.go +++ b/internal/cmd/shell/executor.go @@ -314,8 +314,8 @@ func isBrokenPipe(err error) bool { if errors.Is(err, syscall.EPIPE) { return true } - var errno syscall.Errno - return errors.As(err, &errno) && errno == syscall.EPIPE + errno, ok := errors.AsType[syscall.Errno](err) + return ok && errno == syscall.EPIPE } // execTest executes a test command to check if something exists diff --git a/nix/checks.nix b/nix/checks.nix index 26ebb66..9ea19ec 100644 --- a/nix/checks.nix +++ b/nix/checks.nix @@ -33,14 +33,11 @@ in git-hooks.lib.${system}.run { inherit src; hooks = { - # Use the pinned Go toolchain's gofmt; git-hooks' default wrapper - # still ships Go 1.26 and rejects go.mod 1.27. + # git-hooks' default gofmt package is pkgs.go (still 1.26). gofmt = { enable = true; - entry = "${go}/bin/gofmt -l -w"; - files = "\\.go$"; + package = go; }; - # Flake-pinned golangci-lint (v2.13.1; nixpkgs-unstable still ships 2.12.2). golangci-lint = { enable = true; package = golangci-lint; diff --git a/nix/golangci-lint.nix b/nix/golangci-lint.nix deleted file mode 100644 index 15b44b8..0000000 --- a/nix/golangci-lint.nix +++ /dev/null @@ -1,61 +0,0 @@ -# golangci-lint built with the project Go toolchain. -# -# nixpkgs-unstable still pins buildGo126Module (v2.12.2), so the stock binary -# rejects go.mod 1.27. Pin the Go 1.27 release until unstable catches up, then -# drop this file and use pkgs.golangci-lint. -{ - buildGoModule, - fetchFromGitHub, - installShellFiles, - lib, - stdenv, - buildPackages, -}: - -buildGoModule (finalAttrs: { - pname = "golangci-lint"; - version = "2.13.1"; - - src = fetchFromGitHub { - owner = "golangci"; - repo = "golangci-lint"; - tag = "v${finalAttrs.version}"; - hash = "sha256-8nWHSMAwIILfKMPfxWKMimxWt9N+kUsZEAaoAOPbRBE="; - }; - - vendorHash = "sha256-yZRqfht5rY2yyoZNtYttE57sB7EYjk71yrKw8dLYzNk="; - - subPackages = [ "cmd/golangci-lint" ]; - - nativeBuildInputs = [ installShellFiles ]; - - ldflags = [ - "-s" - "-w" - "-X main.version=${finalAttrs.version}" - "-X main.commit=${finalAttrs.src.rev}" - "-X main.date=1970-01-01T00:00:00Z" - ]; - - postInstall = - let - golangcilintBin = - if stdenv.buildPlatform.canExecute stdenv.hostPlatform then - "$out" - else - lib.getBin buildPackages.golangci-lint; - in - '' - installShellCompletion --cmd golangci-lint \ - --bash <(${golangcilintBin}/bin/golangci-lint completion bash) \ - --fish <(${golangcilintBin}/bin/golangci-lint completion fish) \ - --zsh <(${golangcilintBin}/bin/golangci-lint completion zsh) - ''; - - meta = { - description = "Fast linters Runner for Go (Go 1.27-capable build)"; - homepage = "https://golangci-lint.run/"; - mainProgram = "golangci-lint"; - license = lib.licenses.gpl3Plus; - }; -})