nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenvNoCC,
4 fetchFromGitHub,
5 zsh,
6 revolver,
7 installShellFiles,
8 testers,
9 nix-update-script,
10}:
11
12stdenvNoCC.mkDerivation (finalAttrs: {
13 pname = "zunit";
14 version = "0.8.2";
15
16 src = fetchFromGitHub {
17 owner = "zunit-zsh";
18 repo = "zunit";
19 rev = "v${finalAttrs.version}";
20 hash = "sha256-kXgJjD7N9pUIk57g/EEXZ8ADypuVO+Vyj8ssgwOzVCg=";
21 # The "tests" folder is missing in GitHub-provided download archives.
22 # work around with `git clone`.
23 # https://github.com/orgs/community/discussions/180774
24 forceFetchGit = true;
25 };
26
27 strictDeps = true;
28 doCheck = true;
29 doInstallCheck = true;
30
31 nativeBuildInputs = [
32 zsh
33 installShellFiles
34 ];
35 nativeCheckInputs = [ revolver ];
36 buildInputs = [
37 zsh
38 revolver
39 ];
40
41 postPatch = ''
42 for i in $(find src/ -type f -print); do
43 substituteInPlace $i \
44 --replace-warn " revolver " " ${lib.getExe revolver} "
45 done
46 '';
47
48 buildPhase = ''
49 runHook preBuild
50
51 zsh build.zsh
52
53 runHook postBuild
54 '';
55
56 checkPhase = ''
57 runHook preCheck
58
59 HOME="$TEMPDIR" zsh zunit
60
61 runHook postCheck
62 '';
63
64 installPhase = ''
65 runHook preInstall
66
67 install -Dm755 zunit $out/bin/zunit
68
69 runHook postInstall
70 '';
71
72 postInstall = ''
73 installShellCompletion --cmd zunit --zsh zunit.zsh-completion
74 '';
75
76 installCheckPhase = ''
77 runHook preInstallCheck
78
79 PATH=$PATH:$out/bin zunit --help
80
81 runHook postInstallCheck
82 '';
83
84 passthru = {
85 tests.version = testers.testVersion { package = finalAttrs.finalPackage; };
86 updateScript = nix-update-script { };
87 };
88
89 meta = {
90 description = "Powerful testing framework for ZSH projects";
91 homepage = "https://zunit.xyz/";
92 downloadPage = "https://github.com/zunit-zsh/zunit/releases";
93 changelog = "https://github.com/zunit-zsh/zunit/releases/tag/${finalAttrs.src.rev}";
94 license = lib.licenses.mit;
95 mainProgram = "zunit";
96 inherit (zsh.meta) platforms;
97 maintainers = with lib.maintainers; [ d-brasher ];
98 };
99})