From 5d30101409789a5dbc92068bf85d47a220e0661f Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 18 Oct 2022 12:28:34 +0200 Subject: [PATCH] tflint: add withPlugins passthru This can be used to build a tflint with plugins like this: ``` tflint.withPlugins (cp: [ cp.tflint-ruleset-aws ]) ``` --- .../tools/analysis/tflint/default.nix | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/pkgs/development/tools/analysis/tflint/default.nix b/pkgs/development/tools/analysis/tflint/default.nix index 1eab36cf78da..1011cacd3661 100644 --- a/pkgs/development/tools/analysis/tflint/default.nix +++ b/pkgs/development/tools/analysis/tflint/default.nix @@ -1,4 +1,12 @@ -{ lib, buildGoModule, fetchFromGitHub }: +{ lib +, buildGoModule +, fetchFromGitHub +, runCommand +, makeWrapper +, tflint +, tflint-plugins +, symlinkJoin +}: buildGoModule rec { pname = "tflint"; @@ -19,6 +27,22 @@ buildGoModule rec { ldflags = [ "-s" "-w" ]; + passthru.withPlugins = plugins: + let + actualPlugins = plugins tflint-plugins; + pluginDir = symlinkJoin { + name = "tflint-plugin-dir"; + paths = [ actualPlugins ]; + }; + in + runCommand "tflint-with-plugins" + { + nativeBuildInputs = [ makeWrapper ]; + } '' + makeWrapper ${tflint}/bin/tflint $out/bin/tflint \ + --set TFLINT_PLUGIN_DIR "${pluginDir}" + ''; + meta = with lib; { description = "Terraform linter focused on possible errors, best practices, and so on"; homepage = "https://github.com/terraform-linters/tflint";