lol
1# TODO tidy up eg The patchelf code is patching gvim even if you don't build it..
2# but I have gvim with python support now :) - Marc
3args@{ source ? "default", callPackage, fetchurl, stdenv, ncurses, pkgconfig, gettext
4, composableDerivation, writeText, lib, config, glib, gtk2, gtk3, python, perl, tcl, ruby
5, libX11, libXext, libSM, libXpm, libXt, libXaw, libXau, libXmu
6, libICE
7
8# apple frameworks
9, CoreServices, CoreData, Cocoa, Foundation, libobjc, cf-private
10
11, ... }: with args;
12
13
14let
15 inherit (args.composableDerivation) composableDerivation edf;
16 nixosRuntimepath = writeText "nixos-vimrc" ''
17 set nocompatible
18 syntax on
19
20 function! NixosPluginPath()
21 let seen = {}
22 for p in reverse(split($NIX_PROFILES))
23 for d in split(glob(p . '/share/vim-plugins/*'))
24 let pluginname = substitute(d, ".*/", "", "")
25 if !has_key(seen, pluginname)
26 exec 'set runtimepath^='.d
27 let after = d."/after"
28 if isdirectory(after)
29 exec 'set runtimepath^='.after
30 endif
31 let seen[pluginname] = 1
32 endif
33 endfor
34 endfor
35 endfunction
36
37 execute NixosPluginPath()
38
39 if filereadable("/etc/vimrc")
40 source /etc/vimrc
41 elseif filereadable("/etc/vim/vimrc")
42 source /etc/vim/vimrc
43 endif
44 '';
45
46 common = callPackage ./common.nix {};
47in
48composableDerivation {
49} (fix: rec {
50
51 name = "vim_configurable-${version}";
52
53 inherit (common) version postPatch hardeningDisable enableParallelBuilding meta;
54
55 src = builtins.getAttr source {
56 "default" = common.src; # latest release
57
58 "vim-nox" =
59 {
60 # vim nox branch: client-server without X by uing sockets
61 # REGION AUTO UPDATE: { name="vim-nox"; type="hg"; url="https://code.google.com/r/yukihironakadaira-vim-cmdsrv-nox/"; branch="cmdsrv-nox"; }
62 src = (fetchurl { url = "http://mawercer.de/~nix/repos/vim-nox-hg-2082fc3.tar.bz2"; sha256 = "293164ca1df752b7f975fd3b44766f5a1db752de6c7385753f083499651bd13a"; });
63 name = "vim-nox-hg-2082fc3";
64 # END
65 }.src;
66 };
67
68 patches = [ ./cflags-prune.diff ];
69
70 configureFlags
71 = [ "--enable-gui=${args.gui}" "--with-features=${args.features}" ];
72
73 nativeBuildInputs = [ pkgconfig ];
74
75 buildInputs
76 = [ ncurses libX11 libXext libSM libXpm libXt libXaw libXau
77 libXmu glib libICE ] ++ (if args.gui == "gtk3" then [gtk3] else [gtk2]);
78
79 # most interpreters aren't tested yet.. (see python for example how to do it)
80 flags = {
81 ftNix = {
82 patches = [ ./ft-nix-support.patch ];
83 };
84 }
85 // edf {
86 name = "darwin";
87 enable = {
88 buildInputs = [ CoreServices CoreData Cocoa Foundation libobjc cf-private ];
89 NIX_LDFLAGS = stdenv.lib.optional stdenv.isDarwin
90 "/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation";
91 };
92 } #Disable Darwin (macOS) support.
93 // edf { name = "xsmp"; } #Disable XSMP session management
94 // edf { name = "xsmp_interact"; } #Disable XSMP interaction
95 // edf { name = "mzscheme"; feat = "mzschemeinterp";} #Include MzScheme interpreter.
96 // edf { name = "perl"; feat = "perlinterp"; enable = { nativeBuildInputs = [perl]; };} #Include Perl interpreter.
97
98 // edf {
99 name = "python";
100 feat = "python${if python ? isPy3 then "3" else ""}interp";
101 enable = {
102 buildInputs = [ python ];
103 } // lib.optionalAttrs stdenv.isDarwin {
104 configureFlags
105 = [ "--enable-python${if python ? isPy3 then "3" else ""}interp=yes"
106 "--with-python${if python ? isPy3 then "3" else ""}-config-dir=${python}/lib"
107 "--disable-python${if python ? isPy3 then "" else "3"}interp" ];
108 };
109 }
110
111 // edf { name = "tcl"; feat = "tclinterp"; enable = { buildInputs = [tcl]; }; } #Include Tcl interpreter.
112 // edf { name = "ruby"; feat = "rubyinterp"; enable = { buildInputs = [ruby]; };} #Include Ruby interpreter.
113 // edf {
114 name = "lua";
115 feat = "luainterp";
116 enable = {
117 buildInputs = [lua];
118 configureFlags = [
119 "--with-lua-prefix=${args.lua}"
120 "--enable-luainterp"
121 ];
122 };
123 }
124 // edf { name = "cscope"; } #Include cscope interface.
125 // edf { name = "workshop"; } #Include Sun Visual Workshop support.
126 // edf { name = "netbeans"; } #Disable NetBeans integration support.
127 // edf { name = "sniff"; feat = "sniff" ; } #Include Sniff interface.
128 // edf { name = "multibyte"; } #Include multibyte editing support.
129 // edf { name = "hangulinput"; feat = "hangulinput" ;} #Include Hangul input support.
130 // edf { name = "xim"; } #Include XIM input support.
131 // edf { name = "fontset"; } #Include X fontset output support.
132 // edf { name = "acl"; } #Don't check for ACL support.
133 // edf { name = "gpm"; } #Don't use gpm (Linux mouse daemon).
134 // edf { name = "nls"; enable = {nativeBuildInputs = [gettext];}; } #Don't support NLS (gettext()).
135 ;
136
137 cfg = {
138 luaSupport = config.vim.lua or true;
139 pythonSupport = config.vim.python or true;
140 rubySupport = config.vim.ruby or true;
141 nlsSupport = config.vim.nls or false;
142 tclSupport = config.vim.tcl or false;
143 multibyteSupport = config.vim.multibyte or false;
144 cscopeSupport = config.vim.cscope or true;
145 netbeansSupport = config.netbeans or true; # eg envim is using it
146 ximSupport = config.vim.xim or true; # less than 15KB, needed for deadkeys
147
148 # by default, compile with darwin support if we're compiling on darwin, but
149 # allow this to be disabled by setting config.vim.darwin to false
150 darwinSupport = stdenv.isDarwin && (config.vim.darwin or true);
151
152 # add .nix filetype detection and minimal syntax highlighting support
153 ftNixSupport = config.vim.ftNix or true;
154 };
155
156 #--enable-gui=OPTS X11 GUI default=auto OPTS=auto/no/gtk/gtk2/gtk3/gnome/gnome2/motif/athena/neXtaw/photon/carbon
157 /*
158 // edf "gtk_check" "gtk_check" { } #If auto-select GUI, check for GTK default=yes
159 // edf "gtk2_check" "gtk2_check" { } #If GTK GUI, check for GTK+ 2 default=yes
160 // edf "gnome_check" "gnome_check" { } #If GTK GUI, check for GNOME default=no
161 // edf "motif_check" "motif_check" { } #If auto-select GUI, check for Motif default=yes
162 // edf "athena_check" "athena_check" { } #If auto-select GUI, check for Athena default=yes
163 // edf "nextaw_check" "nextaw_check" { } #If auto-select GUI, check for neXtaw default=yes
164 // edf "carbon_check" "carbon_check" { } #If auto-select GUI, check for Carbon default=yes
165 // edf "gtktest" "gtktest" { } #Do not try to compile and run a test GTK program
166 */
167
168 preInstall = ''
169 mkdir -p $out/share/applications $out/share/icons/{hicolor,locolor}/{16x16,32x32,48x48}/apps
170 '';
171
172 postInstall = stdenv.lib.optionalString stdenv.isLinux ''
173 patchelf --set-rpath \
174 "$(patchelf --print-rpath $out/bin/vim):${lib.makeLibraryPath buildInputs}" \
175 "$out"/bin/{vim,gvim}
176
177 ln -sfn '${nixosRuntimepath}' "$out"/share/vim/vimrc
178 '';
179
180 dontStrip = 1;
181})