about summary refs log tree commit diff
path: root/pkgs/applications/editors/vim/macvim.nix
blob: d7156321f1db4de04c98c09b808be31fd42f4e0a (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
92
93
94
95
{ stdenv, fetchFromGitHub, ncurses, gettext,
  pkgconfig, cscope, python, ruby, tcl, perl, luajit
}:

stdenv.mkDerivation rec {
  name = "macvim-${version}";

  version = "7.4.479";

  src = fetchFromGitHub {
    owner = "genoma";
    repo = "macvim";
    rev = "f9c084b97fa9d5cad2448dfd3eff3d9b7f0fac59";
    sha256 = "1f6l39s6cgyzzr9ix729axmc299mpl29abbc7571g4vply17m7nv";
  };

  enableParallelBuilding = true;

  buildInputs = [
    gettext ncurses pkgconfig luajit ruby tcl perl python
  ];

  patches = [ ./macvim.patch ];

  postPatch = ''
    substituteInPlace src/MacVim/mvim --replace "# VIM_APP_DIR=/Applications" "VIM_APP_DIR=$out/Applications"

    # Don't create custom icons.
    substituteInPlace src/MacVim/icons/Makefile --replace '$(MAKE) -C makeicns' ""
    substituteInPlace src/MacVim/icons/make_icons.py --replace "dont_create = False" "dont_create = True"

    # Full path to xcodebuild
    substituteInPlace src/Makefile --replace "xcodebuild" "/usr/bin/xcodebuild"
  '';

  configureFlags = [
      #"--enable-cscope" # TODO: cscope doesn't build on Darwin yet
      "--enable-fail-if-missing"
      "--with-features=huge"
      "--enable-gui=macvim"
      "--enable-multibyte"
      "--enable-nls"
      "--enable-luainterp=dynamic"
      "--enable-pythoninterp=dynamic"
      "--enable-perlinterp=dynamic"
      "--enable-rubyinterp=dynamic"
      "--enable-tclinterp=yes"
      "--without-local-dir"
      "--with-luajit"
      "--with-lua-prefix=${luajit}"
      "--with-ruby-command=${ruby}/bin/ruby"
      "--with-tclsh=${tcl}/bin/tclsh"
      "--with-tlib=ncurses"
      "--with-compiledby=Nix"
  ];

  makeFlags = ''PREFIX=$(out) CPPFLAGS="-Wno-error"'';

  preConfigure = ''
    DEV_DIR=$(/usr/bin/xcode-select -print-path)/Platforms/MacOSX.platform/Developer
    configureFlagsArray+=(
      "--with-developer-dir=$DEV_DIR"
    )
  '';

  postInstall = ''
    mkdir -p $out/Applications
    cp -r src/MacVim/build/Release/MacVim.app $out/Applications

    rm $out/bin/{Vimdiff,Vimtutor,Vim,ex,rVim,rview,view}

    cp src/MacVim/mvim $out/bin
    cp src/vimtutor $out/bin

    for prog in "vimdiff" "vi" "vim" "ex" "rvim" "rview" "view"; do
      ln -s $out/bin/mvim $out/bin/$prog
    done

    # Fix rpaths
    exe="$out/Applications/MacVim.app/Contents/MacOS/Vim"
    libperl=$(dirname $(find ${perl} -name "libperl.dylib"))
    install_name_tool -add_rpath ${luajit}/lib $exe
    install_name_tool -add_rpath ${tcl}/lib $exe
    install_name_tool -add_rpath ${python}/lib $exe
    install_name_tool -add_rpath $libperl $exe
    install_name_tool -add_rpath ${ruby}/lib $exe
  '';

  meta = with stdenv.lib; {
    description = "Vim - the text editor - for Mac OS X";
    homepage    = https://github.com/b4winckler/macvim;
    maintainers = with maintainers; [ cstrahan ];
    platforms   = platforms.darwin;
  };
}