about summary refs log tree commit diff
path: root/nixpkgs/pkgs/shells/zsh/zsh-fzf-tab/default.nix
blob: dcb3ffd19ec7f520151da471798a77b1edbef40f (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
{ stdenv, lib, fetchFromGitHub, zsh, ncurses, nix-update-script }:

let
  INSTALL_PATH="${placeholder "out"}/share/fzf-tab";
in stdenv.mkDerivation rec {
  pname = "zsh-fzf-tab";
  version = "1.1.1";

  src = fetchFromGitHub {
    owner = "Aloxaf";
    repo = "fzf-tab";
    rev = "v${version}";
    hash = "sha256-0/YOL1/G2SWncbLNaclSYUz7VyfWu+OB8TYJYm4NYkM=";
  };

  strictDeps = true;
  buildInputs = [ ncurses ];

  # https://github.com/Aloxaf/fzf-tab/issues/337
  env = lib.optionalAttrs stdenv.cc.isClang {
    NIX_CFLAGS_COMPILE = toString [
      "-Wno-error=implicit-function-declaration"
      "-Wno-error=implicit-int"
    ];
  };

  # this script is modified according to fzf-tab/lib-ftb-build-module
  configurePhase = ''
    runHook preConfigure

    pushd modules

    tar -xf ${zsh.src}
    ln -s $(pwd)/Src/fzftab.c zsh-${zsh.version}/Src/Modules/
    ln -s $(pwd)/Src/fzftab.mdd zsh-${zsh.version}/Src/Modules/

    pushd zsh-${zsh.version}


    if [[ ! -f ./configure ]]; then
      ./Util/preconfig
    fi
    if [[ ! -f ./Makefile ]]; then
      ./configure --disable-gdbm --without-tcsetpgrp
    fi

    popd
    popd

    runHook postConfigure
  '';

  buildPhase = ''
    runHook preBuild

    pushd modules/zsh-${zsh.version}
    make -j$NIX_BUILD_CORES
    popd

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p ${INSTALL_PATH}
    cp -r lib ${INSTALL_PATH}/lib
    install -D fzf-tab.zsh ${INSTALL_PATH}/fzf-tab.zsh
    install -D fzf-tab.plugin.zsh ${INSTALL_PATH}/fzf-tab.plugin.zsh
    pushd modules/zsh-${zsh.version}/Src/Modules
    if [[ -e "fzftab.so" ]]; then
       install -D -t ${INSTALL_PATH}/modules/Src/aloxaf/ fzftab.so
    fi
    if [[ -e "fzftab.bundle" ]]; then
       install -D -t ${INSTALL_PATH}/modules/Src/aloxaf/ fzftab.bundle
    fi
    popd

    runHook postInstall
  '';

  passthru.updateScript = nix-update-script { };

  meta = with lib; {
    homepage = "https://github.com/Aloxaf/fzf-tab";
    description = "Replace zsh's default completion selection menu with fzf!";
    license = licenses.mit;
    maintainers = with maintainers; [ vonfry ];
    platforms = platforms.unix;
  };
}