From a44e3553f776154baba862e12c22e64c7303d2d7 Mon Sep 17 00:00:00 2001 From: Thibault Gagnaux Date: Fri, 4 Apr 2025 17:19:52 +0200 Subject: [PATCH] bashunit: init at 0.19.0 Co-authored-by: emaryn <197520219+emaryn@users.noreply.github.com> --- pkgs/by-name/ba/bashunit/package.nix | 78 ++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 pkgs/by-name/ba/bashunit/package.nix diff --git a/pkgs/by-name/ba/bashunit/package.nix b/pkgs/by-name/ba/bashunit/package.nix new file mode 100644 index 000000000000..d458858dfdd0 --- /dev/null +++ b/pkgs/by-name/ba/bashunit/package.nix @@ -0,0 +1,78 @@ +{ + stdenvNoCC, + lib, + fetchFromGitHub, + bash, + which, + versionCheckHook, + coreutils, + makeBinaryWrapper, + nix-update-script, +}: + +stdenvNoCC.mkDerivation (finalAttrs: { + pname = "bashunit"; + version = "0.19.0"; + src = fetchFromGitHub { + owner = "TypedDevs"; + repo = "bashunit"; + tag = finalAttrs.version; + hash = "sha256-EoCCqESzmCW12AuAqA3qh2VcE8gyUPIGJEoCcZhMA/Y="; + forceFetchGit = true; # needed to include the tests directory for the check phase + }; + + nativeBuildInputs = [ makeBinaryWrapper ]; + + postConfigure = '' + patchShebangs src tests build.sh bashunit + substituteInPlace Makefile \ + --replace-fail "SHELL=/bin/bash" "SHELL=${lib.getExe bash}" + ''; + + buildPhase = '' + runHook preBuild + ./build.sh + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + install -m755 -D bin/bashunit $out/bin/bashunit + runHook postInstall + ''; + + # some tests are currently broken on linux and it is not easy to disable them + # reenable them after https://github.com/TypedDevs/bashunit/pull/397 has been merged + doCheck = false; + nativeCheckInputs = [ which ]; + checkPhase = '' + runHook preCheck + make test + runHook postCheck + ''; + + postFixup = '' + wrapProgram $out/bin/bashunit \ + --prefix PATH : "${ + lib.makeBinPath [ + coreutils + which + ] + }" + ''; + + nativeInstallCheckInputs = [ versionCheckHook ]; + doInstallCheck = true; + versionCheckProgramArg = "--version"; + + passthru.updateScript = nix-update-script { }; + + meta = { + description = "Simple testing framework for bash scripts"; + homepage = "https://bashunit.typeddevs.com"; + changelog = "https://github.com/TypedDevs/bashunit/releases/tag/${finalAttrs.version}"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ tricktron ]; + mainProgram = "bashunit"; + }; +})