1{ lib
2, buildGoModule
3, fetchFromGitHub
4, runCommand
5, makeWrapper
6, tflint
7, tflint-plugins
8, symlinkJoin
9}:
10
11buildGoModule rec {
12 pname = "tflint";
13 version = "0.49.0";
14
15 src = fetchFromGitHub {
16 owner = "terraform-linters";
17 repo = pname;
18 rev = "v${version}";
19 hash = "sha256-udP11icQp90u8hmDkg9nKQYPvHFDLeylQS6sLS74ErY=";
20 };
21
22 vendorHash = "sha256-sSWDy8LsqRP4DNuWI8HhE6ojjnHx2Ltyw55oaGOa1ms=";
23
24 doCheck = false;
25
26 subPackages = [ "." ];
27
28 ldflags = [ "-s" "-w" ];
29
30 passthru.withPlugins = plugins:
31 let
32 actualPlugins = plugins tflint-plugins;
33 pluginDir = symlinkJoin {
34 name = "tflint-plugin-dir";
35 paths = [ actualPlugins ];
36 };
37 in
38 runCommand "tflint-with-plugins"
39 {
40 nativeBuildInputs = [ makeWrapper ];
41 } ''
42 makeWrapper ${tflint}/bin/tflint $out/bin/tflint \
43 --set TFLINT_PLUGIN_DIR "${pluginDir}"
44 '';
45
46 meta = with lib; {
47 description = "Terraform linter focused on possible errors, best practices, and so on";
48 homepage = "https://github.com/terraform-linters/tflint";
49 changelog = "https://github.com/terraform-linters/tflint/blob/v${version}/CHANGELOG.md";
50 license = licenses.mpl20;
51 maintainers = [ maintainers.marsam ];
52 };
53}