1{
2 stdenvNoCC,
3 lib,
4 fetchFromGitHub,
5 bash,
6 which,
7 versionCheckHook,
8 coreutils,
9 makeBinaryWrapper,
10 nix-update-script,
11}:
12
13stdenvNoCC.mkDerivation (finalAttrs: {
14 pname = "bashunit";
15 version = "0.22.3";
16
17 src = fetchFromGitHub {
18 owner = "TypedDevs";
19 repo = "bashunit";
20 tag = finalAttrs.version;
21 hash = "sha256-CN3BmsAFRQSkcS97XkKsL9+lChxb7V05iw8xoq0QVZE=";
22 forceFetchGit = true; # needed to include the tests directory for the check phase
23 };
24
25 nativeBuildInputs = [ makeBinaryWrapper ];
26
27 postConfigure = ''
28 patchShebangs tests build.sh bashunit
29 substituteInPlace Makefile \
30 --replace-fail "SHELL=/bin/bash" "SHELL=${lib.getExe bash}"
31 '';
32
33 buildPhase = ''
34 runHook preBuild
35 ./build.sh
36 runHook postBuild
37 '';
38
39 installPhase = ''
40 runHook preInstall
41 install -m755 -D bin/bashunit $out/bin/bashunit
42 runHook postInstall
43 '';
44
45 doCheck = true;
46 nativeCheckInputs = [ which ];
47 checkPhase = ''
48 runHook preCheck
49 make test
50 runHook postCheck
51 '';
52
53 postFixup = ''
54 wrapProgram $out/bin/bashunit \
55 --prefix PATH : "${
56 lib.makeBinPath [
57 coreutils
58 which
59 ]
60 }"
61 '';
62
63 nativeInstallCheckInputs = [ versionCheckHook ];
64 doInstallCheck = true;
65 versionCheckProgramArg = "--version";
66
67 passthru.updateScript = nix-update-script { };
68
69 meta = {
70 description = "Simple testing framework for bash scripts";
71 homepage = "https://bashunit.typeddevs.com";
72 changelog = "https://github.com/TypedDevs/bashunit/releases/tag/${finalAttrs.version}";
73 license = lib.licenses.mit;
74 maintainers = with lib.maintainers; [ tricktron ];
75 mainProgram = "bashunit";
76 };
77})