diff --git a/README.md b/README.md index f7c21337..6f2afb20 100644 --- a/README.md +++ b/README.md @@ -423,6 +423,7 @@ use nix - [topiary](https://github.com/tweag/topiary) - [treefmt](https://github.com/numtide/treefmt) - [trim-trailing-whitespace](https://github.com/pre-commit/pre-commit-hooks/blob/main/pre_commit_hooks/trailing_whitespace_fixer.py) +- [woodpecker-cli-lint](https://woodpecker-ci.org/docs/cli#lint) ### Custom hooks diff --git a/modules/hooks.nix b/modules/hooks.nix index 7d0ecc58..d3efe96b 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -2,7 +2,7 @@ let inherit (config) hooks tools settings; cfg = config; - inherit (lib) flatten mapAttrs mapAttrsToList mkDefault mkOption mkRemovedOptionModule mkRenamedOptionModule types; + inherit (lib) flatten mapAttrs mapAttrsToList mkDefault mkOption mkEnableOption mkRemovedOptionModule mkRenamedOptionModule types; cargoManifestPathArg = lib.optionalString @@ -1942,6 +1942,40 @@ in }; }; }; + woodpecker-cli-lint = mkOption { + description = "`woodpecker-cli lint` hook"; + type = types.submodule { + imports = [ hookModule ]; + options.settings = { + workflowPath = mkOption { + type = types.str; + description = '' + Path to the workflow config file/directory. If not set, the program + looks for `.woodpecker.ya?ml` file or `.woodpecker` directory. + ''; + default = ""; + example = ".woodpecker.yml"; + }; + strict = mkEnableOption "" // { + description = "Whether to treat warnings as errors."; + }; + pluginsPrivileged = mkOption { + type = types.commas; + description="List of plugins, allowed to run in privileged mode"; + default=""; + }; + pluginsTrustedClone = mkOption { + type = types.commas; + description='' + List of plugins, that are trusted to handle Git credentials in cloning steps. + If not set, the program defaults to + "docker.io/woodpeckerci/plugin-git:2.6.3,docker.io/woodpeckerci/plugin-git,quay.io/woodpeckerci/plugin-git". + ''; + default=""; + }; + }; + }; + }; yamlfmt = mkOption { description = "yamlfmt hook"; type = types.submodule { @@ -4050,6 +4084,24 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.fourm "${hooks.vale.package}/bin/vale${cmdArgs} ${hooks.vale.settings.flags}"; types = [ "text" ]; }; + woodpecker-cli-lint = { + name = "woodpecker-cli-lint"; + description = "Command line client for the Woodpecker Continuous Integration server (lint only)."; + package = tools.woodpecker-cli; + entry = let + cmdArgs = mkCmdArgs (with hooks.woodpecker-cli-lint.settings; [ + [ (workflowPath != "") workflowPath ] + # this check depends on the internet connection, without it + # the lint is lightning-fast + [ true "--disable-update-check" ] + [ strict "--strict" ] + [ (pluginsPrivileged != "") "--plugins-privileged=${pluginsPrivileged}" ] + [ (pluginsTrustedClone != "") "--plugins-trusted-clone=${pluginsTrustedClone}" ] + ]); + in + "${lib.getExe hooks.woodpecker-cli-lint.package} lint ${cmdArgs}"; + types = [ "file" "yaml" ]; + }; yamlfmt = { name = "yamlfmt"; diff --git a/nix/tools.nix b/nix/tools.nix index 2ef42b80..ed6093fa 100644 --- a/nix/tools.nix +++ b/nix/tools.nix @@ -85,6 +85,7 @@ , typos , typstfmt , typstyle ? null ## Add in nixpkgs added on commit 800ca60 +, woodpecker-cli , zprint , yamlfmt , yamllint @@ -173,6 +174,7 @@ in typstfmt typstyle vale + woodpecker-cli yamlfmt yamllint zprint