From 751e9b6c7f8de129532df03806cadf5dc86e9b5d Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Mon, 1 Apr 2024 03:31:24 +0800 Subject: [PATCH] writeShellApplication: add argument extraShellCheckFlags --- pkgs/build-support/trivial-builders/default.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/trivial-builders/default.nix b/pkgs/build-support/trivial-builders/default.nix index d7438923a54b..1625b0c96719 100644 --- a/pkgs/build-support/trivial-builders/default.nix +++ b/pkgs/build-support/trivial-builders/default.nix @@ -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 ''