1{ lib, stdenv, fetchurl
2, fetchpatch
3, autoreconfHook
4, perl
5, ps
6, python3Packages
7, bashInteractive
8}:
9
10stdenv.mkDerivation rec {
11 pname = "bash-completion";
12 version = "2.11";
13
14 # Using fetchurl because fetchGithub or fetchzip will have trouble on
15 # e.g. APFS filesystems (macOS) because of non UTF-8 characters in some of the
16 # test fixtures that are part of the repository.
17 # See discussion in https://github.com/NixOS/nixpkgs/issues/107768
18 src = fetchurl {
19 url = "https://github.com/scop/${pname}/releases/download/${version}/${pname}-${version}.tar.xz";
20 sha256 = "1b0iz7da1sgifx1a5wdyx1kxbzys53v0kyk8nhxfipllmm5qka3k";
21 };
22
23 nativeBuildInputs = [ autoreconfHook ];
24
25 # tests are super flaky unfortunately, and regularily break.
26 # let's disable them for now.
27 doCheck = false;
28 checkInputs = [
29 # perl is assumed by perldoc completion
30 perl
31 # ps assumed to exist by gdb, killall, pgrep, pidof,
32 # pkill, pwdx, renice, and reptyr completions
33 ps
34 python3Packages.pexpect
35 python3Packages.pytest
36 bashInteractive
37 ];
38
39 # - ignore test_gcc on ARM because it assumes -march=native
40 # - ignore test_chsh because it assumes /etc/shells exists
41 # - ignore test_ether_wake, test_ifdown, test_ifstat, test_ifup,
42 # test_iperf, test_iperf3, test_nethogs and ip_addresses
43 # because they try to touch network
44 # - ignore test_ls because impure logic
45 # - ignore test_screen because it assumes vt terminals exist
46 checkPhase = ''
47 pytest . \
48 ${lib.optionalString (stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isAarch32) "--ignore=test/t/test_gcc.py"} \
49 --ignore=test/t/test_chsh.py \
50 --ignore=test/t/test_ether_wake.py \
51 --ignore=test/t/test_ifdown.py \
52 --ignore=test/t/test_ifstat.py \
53 --ignore=test/t/test_ifup.py \
54 --ignore=test/t/test_iperf.py \
55 --ignore=test/t/test_iperf3.py \
56 --ignore=test/t/test_nethogs.py \
57 --ignore=test/t/unit/test_unit_ip_addresses.py \
58 --ignore=test/t/test_ls.py \
59 --ignore=test/t/test_screen.py
60 '';
61
62 prePatch = lib.optionalString stdenv.isDarwin ''
63 sed -i -e 's/readlink -f/readlink/g' bash_completion completions/*
64 '';
65
66 meta = with lib; {
67 homepage = "https://github.com/scop/bash-completion";
68 description = "Programmable completion for the bash shell";
69 license = licenses.gpl2Plus;
70 platforms = platforms.unix;
71 maintainers = [ maintainers.xfix ];
72 };
73}