summary refs log tree commit diff
path: root/pkgs/shells/bash/bash-completion/default.nix
blob: e5ef70e43a99d6d3e00b1fb13f8c90bfa40f6fc0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{ stdenv, fetchFromGitHub
, fetchpatch
, autoreconfHook
, perl
, ps
, python3Packages
, bashInteractive
}:

stdenv.mkDerivation rec {
  pname = "bash-completion";
  version = "2.10";

  src = fetchFromGitHub {
    owner = "scop";
    repo = "bash-completion";
    rev = version;
    sha256 = "047yjryy9d6hp18wkigbfrw9r0sm31inlsp8l28fhxg8ii032sgq";
  };

  nativeBuildInputs = [ autoreconfHook ];

  doCheck = !stdenv.isDarwin;
  checkInputs = [
    # perl is assumed by perldoc completion
    perl
    # ps assumed to exist by gdb, killall, pgrep, pidof,
    # pkill, pwdx, renice, and reptyr completions
    ps
    python3Packages.pexpect
    python3Packages.pytest
    bashInteractive

    # use xdist to speed up the test run, just like upstream:
    # https://github.com/scop/bash-completion/blob/009bf2228c68894629eb6fd17b3dc0f1f6d67615/test/requirements.txt#L4
    python3Packages.pytest_xdist
  ];

  # - ignore test_gcc on ARM because it assumes -march=native
  # - ignore test_chsh because it assumes /etc/shells exists
  # - ignore test_ether_wake, test_ifdown, test_ifstat, test_ifup,
  #   test_iperf, test_iperf3, test_nethogs and ip_addresses
  #   because they try to touch network
  # - ignore test_ls because impure logic
  # - ignore test_screen because it assumes vt terminals exist
  checkPhase = ''
    pytest -n $NIX_BUILD_CORES . \
      ${stdenv.lib.optionalString (stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isAarch32) "--ignore=test/t/test_gcc.py"} \
      --ignore=test/t/test_chsh.py \
      --ignore=test/t/test_ether_wake.py \
      --ignore=test/t/test_ifdown.py \
      --ignore=test/t/test_ifstat.py \
      --ignore=test/t/test_ifup.py \
      --ignore=test/t/test_iperf.py \
      --ignore=test/t/test_iperf3.py \
      --ignore=test/t/test_nethogs.py \
      --ignore=test/t/unit/test_unit_ip_addresses.py \
      --ignore=test/t/test_ls.py \
      --ignore=test/t/test_screen.py
  '';

  prePatch = stdenv.lib.optionalString stdenv.isDarwin ''
    sed -i -e 's/readlink -f/readlink/g' bash_completion completions/*
  '';

  meta = with stdenv.lib; {
    homepage = "https://github.com/scop/bash-completion";
    description = "Programmable completion for the bash shell";
    license = licenses.gpl2Plus;
    platforms = platforms.unix;
    maintainers = [ maintainers.peti maintainers.xfix ];
  };
}