nixpkgs/pkgs/build-support/testers/shellcheck/tester.nix
Robert Hensing 3fb14db08a testers.shellcheck: init
Needed for testing upcoming commit.
2024-07-16 20:10:02 +02:00

29 lines
692 B
Nix

# Dependencies (callPackage)
{ lib, stdenv, shellcheck }:
# testers.shellcheck function
# Docs: doc/build-helpers/testers.chapter.md
# Tests: ./tests.nix
{ src }:
let
inherit (lib) fileset pathType isPath;
in
stdenv.mkDerivation {
name = "run-shellcheck";
src =
if isPath src && pathType src == "regular" # note that for strings this would have been IFD, which we prefer to avoid
then fileset.toSource { root = dirOf src; fileset = src; }
else src;
nativeBuildInputs = [ shellcheck ];
doCheck = true;
dontConfigure = true;
dontBuild = true;
checkPhase = ''
find . -type f -print0 \
| xargs -0 shellcheck
'';
installPhase = ''
touch $out
'';
}