1{ stdenv, fetchurl, ncurses, gettext,
2 pkgconfig, cscope, python, ruby, tcl, perl, luajit
3}:
4
5stdenv.mkDerivation rec {
6 name = "macvim-${version}";
7
8 version = "7.4.648";
9
10 src = fetchurl {
11 url = "https://github.com/genoma/macvim/archive/g-snapshot-32.tar.gz";
12 sha256 = "1wqg5sy7krgqg3sj00gb34avg90ga2kbvv09bsxv2267j7agi0iq";
13 };
14
15 enableParallelBuilding = true;
16
17 buildInputs = [
18 gettext ncurses pkgconfig luajit ruby tcl perl python
19 ];
20
21 patches = [ ./macvim.patch ];
22
23 postPatch = ''
24 substituteInPlace src/MacVim/mvim --replace "# VIM_APP_DIR=/Applications" "VIM_APP_DIR=$out/Applications"
25
26 # Don't create custom icons.
27 substituteInPlace src/MacVim/icons/Makefile --replace '$(MAKE) -C makeicns' ""
28 substituteInPlace src/MacVim/icons/make_icons.py --replace "dont_create = False" "dont_create = True"
29
30 # Full path to xcodebuild
31 substituteInPlace src/Makefile --replace "xcodebuild" "/usr/bin/xcodebuild"
32 '';
33
34 configureFlags = [
35 #"--enable-cscope" # TODO: cscope doesn't build on Darwin yet
36 "--enable-fail-if-missing"
37 "--with-features=huge"
38 "--enable-gui=macvim"
39 "--enable-multibyte"
40 "--enable-nls"
41 "--enable-luainterp=dynamic"
42 "--enable-pythoninterp=dynamic"
43 "--enable-perlinterp=dynamic"
44 "--enable-rubyinterp=dynamic"
45 "--enable-tclinterp=yes"
46 "--without-local-dir"
47 "--with-luajit"
48 "--with-lua-prefix=${luajit}"
49 "--with-ruby-command=${ruby}/bin/ruby"
50 "--with-tclsh=${tcl}/bin/tclsh"
51 "--with-tlib=ncurses"
52 "--with-compiledby=Nix"
53 ];
54
55 makeFlags = ''PREFIX=$(out) CPPFLAGS="-Wno-error"'';
56
57 preConfigure = ''
58 DEV_DIR=$(/usr/bin/xcode-select -print-path)/Platforms/MacOSX.platform/Developer
59 configureFlagsArray+=(
60 "--with-developer-dir=$DEV_DIR"
61 )
62 '';
63
64 postInstall = ''
65 mkdir -p $out/Applications
66 cp -r src/MacVim/build/Release/MacVim.app $out/Applications
67
68 rm $out/bin/{Vimdiff,Vimtutor,Vim,ex,rVim,rview,view}
69
70 cp src/MacVim/mvim $out/bin
71 cp src/vimtutor $out/bin
72
73 for prog in "vimdiff" "vi" "vim" "ex" "rvim" "rview" "view"; do
74 ln -s $out/bin/mvim $out/bin/$prog
75 done
76
77 # Fix rpaths
78 exe="$out/Applications/MacVim.app/Contents/MacOS/Vim"
79 libperl=$(dirname $(find ${perl} -name "libperl.dylib"))
80 install_name_tool -add_rpath ${luajit}/lib $exe
81 install_name_tool -add_rpath ${tcl}/lib $exe
82 install_name_tool -add_rpath ${python}/lib $exe
83 install_name_tool -add_rpath $libperl $exe
84 install_name_tool -add_rpath ${ruby}/lib $exe
85 '';
86
87 meta = with stdenv.lib; {
88 description = "Vim - the text editor - for Mac OS X";
89 homepage = https://github.com/b4winckler/macvim;
90 license = licenses.vim;
91 maintainers = with maintainers; [ cstrahan ];
92 platforms = platforms.darwin;
93 };
94}