1{ lib, stdenv, fetchurl
2, autoreconfHook
3, perl
4, ps
5, python3Packages
6, bashInteractive
7}:
8
9stdenv.mkDerivation rec {
10 pname = "bash-completion";
11 version = "2.14.0";
12
13 # Using fetchurl because fetchGithub or fetchzip will have trouble on
14 # e.g. APFS filesystems (macOS) because of non UTF-8 characters in some of the
15 # test fixtures that are part of the repository.
16 # See discussion in https://github.com/NixOS/nixpkgs/issues/107768
17 src = fetchurl {
18 url = "https://github.com/scop/bash-completion/releases/download/${version}/bash-completion-${version}.tar.xz";
19 sha256 = "sha256-XHSU+WgoCDLWrbWqGfdFpW8aed8xHlkzjF76b3KF4Wg=";
20 };
21
22 strictDeps = true;
23 nativeBuildInputs = [ autoreconfHook ];
24
25 # tests are super flaky unfortunately, and regularly break.
26 # let's disable them for now.
27 doCheck = false;
28 nativeCheckInputs = [
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.isAarch "--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 = with maintainers; [ philiptaron ];
72 };
73}