Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
feat(programs): add golangci-lint (hercules-ci#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
folliehiyuki authored Dec 4, 2023
1 parent e82f32a commit affe7fc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ This repo contains a top-level `default.nix` that returns the library helper fun
* fnlfmt
* gofmt
* gofumpt
* golangci-lint
* google-java-format
* hclfmt
* hlint
Expand Down
6 changes: 6 additions & 0 deletions examples/formatter-golangci-lint.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Example generated by ../examples.sh
[formatter.golangci-lint]
command = "golangci-lint"
excludes = []
includes = ["*.go"]
options = ["run"]
26 changes: 26 additions & 0 deletions programs/golangci-lint.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{ lib, pkgs, config, ... }:
let
cfg = config.programs.golangci-lint;
in
{
options.programs.golangci-lint = {
enable = lib.mkEnableOption "golangci-lint";
package = lib.mkPackageOption pkgs "golangci-lint" { };
goPackage = lib.mkPackageOption pkgs "go" { };
};

config = lib.mkIf cfg.enable {
settings.formatter.golangci-lint = {
command = pkgs.writeShellApplication {
name = "golangci-lint";
runtimeInputs = [
cfg.package
cfg.goPackage
];
text = "${cfg.package}/bin/golangci-lint \"$@\"";
};
options = [ "run" ];
includes = [ "*.go" ];
};
};
}

0 comments on commit affe7fc

Please sign in to comment.