1{ lib, stdenv, fetchurl, callPackage, ncurses, bash, gawk, gettext, pkg-config
2# default vimrc
3, vimrc ? fetchurl {
4 name = "default-vimrc";
5 url = "https://raw.githubusercontent.com/archlinux/svntogit-packages/68f6d131750aa778807119e03eed70286a17b1cb/trunk/archlinux.vim";
6 sha256 = "18ifhv5q9prd175q3vxbqf6qyvkk6bc7d2lhqdk0q78i68kv9y0c";
7 }
8# apple frameworks
9, Carbon, Cocoa
10}:
11
12let
13 common = callPackage ./common.nix {};
14in
15stdenv.mkDerivation {
16 pname = "vim";
17
18 inherit (common) version src postPatch hardeningDisable enableParallelBuilding enableParallelInstalling meta;
19
20 nativeBuildInputs = [ gettext pkg-config ];
21 buildInputs = [ ncurses bash gawk ]
22 ++ lib.optionals stdenv.hostPlatform.isDarwin [ Carbon Cocoa ];
23
24 strictDeps = true;
25
26 configureFlags = [
27 "--enable-multibyte"
28 "--enable-nls"
29 ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
30 "vim_cv_toupper_broken=no"
31 "--with-tlib=ncurses"
32 "vim_cv_terminfo=yes"
33 "vim_cv_tgetent=zero" # it does on native anyway
34 "vim_cv_timer_create=yes"
35 "vim_cv_tty_group=tty"
36 "vim_cv_tty_mode=0660"
37 "vim_cv_getcwd_broken=no"
38 "vim_cv_stat_ignores_slash=yes"
39 "vim_cv_memmove_handles_overlap=yes"
40 ];
41
42 # which.sh is used to for vim's own shebang patching, so make it find
43 # binaries for the host platform.
44 preConfigure = ''
45 export HOST_PATH
46 substituteInPlace src/which.sh --replace '$PATH' '$HOST_PATH'
47 '';
48
49 postInstall = ''
50 ln -s $out/bin/vim $out/bin/vi
51 mkdir -p $out/share/vim
52 cp "${vimrc}" $out/share/vim/vimrc
53
54 # Prevent bugs in the upstream makefile from silently failing and missing outputs.
55 # Some of those are build-time requirements for other packages.
56 for tool in ex xxd vi view vimdiff; do
57 if [ ! -e "$out/bin/$tool" ]; then
58 echo "ERROR: install phase did not install '$tool'."
59 exit 1
60 fi
61 done
62 '';
63
64 __impureHostDeps = [ "/dev/ptmx" ];
65
66 # To fix the trouble in vim73, that it cannot cross-build with this patch
67 # to bypass a configure script check that cannot be done cross-building.
68 # http://groups.google.com/group/vim_dev/browse_thread/thread/66c02efd1523554b?pli=1
69 # patchPhase = ''
70 # sed -i -e 's/as_fn_error.*int32.*/:/' src/auto/configure
71 # '';
72}