tflint: add withPlugins passthru

This can be used to build a tflint with plugins like this:

```
tflint.withPlugins (cp: [ cp.tflint-ruleset-aws ])
```
This commit is contained in:
Florian Klink 2022-10-18 12:28:34 +02:00
parent a7f9b63b5d
commit 5d30101409

View file

@ -1,4 +1,12 @@
{ lib, buildGoModule, fetchFromGitHub }: { lib
, buildGoModule
, fetchFromGitHub
, runCommand
, makeWrapper
, tflint
, tflint-plugins
, symlinkJoin
}:
buildGoModule rec { buildGoModule rec {
pname = "tflint"; pname = "tflint";
@ -19,6 +27,22 @@ buildGoModule rec {
ldflags = [ "-s" "-w" ]; 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; { meta = with lib; {
description = "Terraform linter focused on possible errors, best practices, and so on"; description = "Terraform linter focused on possible errors, best practices, and so on";
homepage = "https://github.com/terraform-linters/tflint"; homepage = "https://github.com/terraform-linters/tflint";