Merge pull request #300538 from ShamrockLee/write-shell-application-extra

writeShellApplication: add argument extraShellCheckFlags
This commit is contained in:
Peder Bergebakken Sundt 2024-04-22 22:45:44 +02:00 committed by GitHub
commit 088cdb337b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 2 deletions

View File

@ -233,6 +233,12 @@ rec {
Type: [String]
*/
excludeShellChecks ? [ ],
/*
Extra command-line flags to pass to ShellCheck.
Type: [String]
*/
extraShellCheckFlags ? [ ],
/*
Bash options to activate with `set -o` at the start of the script.
@ -282,11 +288,11 @@ rec {
# but we still want to use writeShellApplication on those platforms
let
shellcheckSupported = lib.meta.availableOn stdenv.buildPlatform shellcheck-minimal.compiler;
excludeOption = lib.optionalString (excludeShellChecks != [ ]) "--exclude '${lib.concatStringsSep "," excludeShellChecks}'";
excludeFlags = lib.optionals (excludeShellChecks != [ ]) [ "--exclude" (lib.concatStringsSep "," excludeShellChecks) ];
shellcheckCommand = lib.optionalString shellcheckSupported ''
# use shellcheck which does not include docs
# pandoc takes long to build and documentation isn't needed for just running the cli
${lib.getExe shellcheck-minimal} ${excludeOption} "$target"
${lib.getExe shellcheck-minimal} ${lib.escapeShellArgs (excludeFlags ++ extraShellCheckFlags)} "$target"
'';
in
if checkPhase == null then ''