1{ stdenvNoCC, lib, fetchFromGitHub, bats }:
2
3let version = "0.5.0";
4in stdenvNoCC.mkDerivation {
5 pname = "bash-preexec";
6 inherit version;
7
8 src = fetchFromGitHub {
9 owner = "rcaloras";
10 repo = "bash-preexec";
11 rev = version;
12 sha256 = "sha256-+FU5n7EkY78X5nUiW3WN9+6Bf6oiPjsG2MSRCleooFs=";
13 };
14
15 checkInputs = [ bats ];
16
17 dontConfigure = true;
18 doCheck = true;
19 dontBuild = true;
20
21 patchPhase = ''
22 # Needed since the tests expect that HISTCONTROL is set.
23 sed -i '/setup()/a HISTCONTROL=""' test/bash-preexec.bats
24
25 # Skip tests failing with Bats 1.5.0.
26 # See https://github.com/rcaloras/bash-preexec/issues/121
27 sed -i '/^@test.*IFS/,/^}/d' test/bash-preexec.bats
28 '';
29
30 checkPhase = ''
31 bats test
32 '';
33
34 installPhase = ''
35 install -Dm755 $src/bash-preexec.sh $out/share/bash/bash-preexec.sh
36 '';
37
38 meta = with lib; {
39 description = "preexec and precmd functions for Bash just like Zsh";
40 license = licenses.mit;
41 homepage = "https://github.com/rcaloras/bash-preexec";
42 maintainers = [ maintainers.hawkw maintainers.rycee ];
43 platforms = platforms.unix;
44 };
45}