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