summary refs log tree commit diff
path: root/pkgs/shells/bash/bash-completion/default.nix
blob: fb9707c3224fe36d60fc1d75b52a0f77beb15d78 (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
{ stdenv, fetchFromGitHub
, lib
, fetchpatch
, autoreconfHook
, python3Packages
, bashInteractive
}:

stdenv.mkDerivation rec {
  pname = "bash-completion";
  # TODO: Remove musl patch below upon next release!
  version = "2.9";

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

  nativeBuildInputs = [ autoreconfHook ];

  doCheck = !stdenv.isDarwin;
  checkInputs = [
    python3Packages.pexpect
    python3Packages.pytest
    bashInteractive
  ];

  patches = [
    ./0001-Revert-build-Do-cmake-pc-and-profile-variable-replac.patch
  ] ++ lib.optionals stdenv.hostPlatform.isMusl [
    # TODO: Remove when https://github.com/scop/bash-completion/commit/2cdac1b9f24df62a1fa80c1824ee8524c9b02393
    #       is availabe in a release in nixpkgs. see https://github.com/scop/bash-completion/issues/312.
    # Fixes a test failure with musl.
    (fetchpatch {
     url = "https://github.com/scop/bash-completion/commit/2cdac1b9f24df62a1fa80c1824ee8524c9b02393.patch";
     name = "bash-completion-musl-test_iconv-skip-option-completion-if-help-fails";
     sha256 = "1l53d62zf01k625nzw3vcrxky93h7bzdpchgk4argxalrn17ckvb";
    })
  ];

  # ignore ip_addresses because it tries to touch network
  # ignore test_ls because impure logic
  checkPhase = ''
    pytest . \
      --ignore=test/t/unit/test_unit_ip_addresses.py \
      --ignore=test/t/test_ls.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 ];
  };
}