1{
2 source ? "default",
3 callPackage,
4 lib,
5 stdenv,
6 ncurses,
7 pkg-config,
8 gettext,
9 writeText,
10 config,
11 glib,
12 gtk2-x11,
13 gtk3-x11,
14 lua,
15 python3,
16 perl,
17 tcl,
18 ruby,
19 libX11,
20 libXext,
21 libSM,
22 libXpm,
23 libXt,
24 libXaw,
25 libXau,
26 libXmu,
27 libsodium,
28 libICE,
29 vimPlugins,
30 makeWrapper,
31 wrapGAppsHook3,
32
33 features ? "huge", # One of tiny, small, normal, big or huge
34 wrapPythonDrv ? false,
35 guiSupport ? config.vim.gui or (if stdenv.hostPlatform.isDarwin then "gtk2" else "gtk3"),
36 luaSupport ? config.vim.lua or true,
37 perlSupport ? config.vim.perl or false, # Perl interpreter
38 pythonSupport ? config.vim.python or true, # Python interpreter
39 rubySupport ? config.vim.ruby or true, # Ruby interpreter
40 nlsSupport ? config.vim.nls or false, # Enable NLS (gettext())
41 tclSupport ? config.vim.tcl or false, # Include Tcl interpreter
42 multibyteSupport ? config.vim.multibyte or false, # Enable multibyte editing support
43 cscopeSupport ? config.vim.cscope or true, # Enable cscope interface
44 netbeansSupport ? config.netbeans or true, # Enable NetBeans integration support.
45 ximSupport ? config.vim.xim or true, # less than 15KB, needed for deadkeys
46 darwinSupport ? config.vim.darwin or false, # Enable Darwin support
47 ftNixSupport ? config.vim.ftNix or true, # Add nix indentation support from vim-nix (not needed for basic syntax highlighting)
48 sodiumSupport ? config.vim.sodium or true, # Enable sodium based encryption
49}:
50
51let
52 nixosRuntimepath = writeText "nixos-vimrc" ''
53 set nocompatible
54 syntax on
55
56 function! NixosPluginPath()
57 let seen = {}
58 for p in reverse(split($NIX_PROFILES))
59 for d in split(glob(p . '/share/vim-plugins/*'))
60 let pluginname = substitute(d, ".*/", "", "")
61 if !has_key(seen, pluginname)
62 exec 'set runtimepath^='.d
63 let after = d."/after"
64 if isdirectory(after)
65 exec 'set runtimepath^='.after
66 endif
67 let seen[pluginname] = 1
68 endif
69 endfor
70 endfor
71 endfunction
72
73 execute NixosPluginPath()
74
75 if filereadable("/etc/vimrc")
76 source /etc/vimrc
77 elseif filereadable("/etc/vim/vimrc")
78 source /etc/vim/vimrc
79 endif
80 '';
81
82 common = callPackage ./common.nix { };
83
84in
85stdenv.mkDerivation {
86
87 pname = "vim-full";
88
89 inherit (common)
90 version
91 outputs
92 postPatch
93 hardeningDisable
94 enableParallelBuilding
95 meta
96 ;
97
98 src = builtins.getAttr source {
99 default = common.src; # latest release
100 };
101
102 patches = [ ./cflags-prune.diff ];
103
104 configureFlags = [
105 "--with-features=${features}"
106 "--disable-xsmp" # XSMP session management
107 "--disable-xsmp_interact" # XSMP interaction
108 "--disable-workshop" # Sun Visual Workshop support
109 "--disable-sniff" # Sniff interface
110 "--disable-hangulinput" # Hangul input support
111 "--disable-fontset" # X fontset output support
112 "--disable-acl" # ACL support
113 "--disable-gpm" # GPM (Linux mouse daemon)
114 "--disable-mzschemeinterp"
115 "--disable-gtk_check"
116 "--disable-gtk2_check"
117 "--disable-gnome_check"
118 "--disable-motif_check"
119 "--disable-athena_check"
120 "--disable-nextaf_check"
121 "--disable-carbon_check"
122 "--disable-gtktest"
123 ]
124 ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
125 "vim_cv_toupper_broken=no"
126 "--with-tlib=ncurses"
127 "vim_cv_terminfo=yes"
128 "vim_cv_tgetent=zero" # it does on native anyway
129 "vim_cv_tty_group=tty"
130 "vim_cv_tty_mode=0660"
131 "vim_cv_getcwd_broken=no"
132 "vim_cv_stat_ignores_slash=yes"
133 "vim_cv_memmove_handles_overlap=yes"
134 ]
135 ++ lib.optional (guiSupport == "gtk2" || guiSupport == "gtk3") "--enable-gui=${guiSupport}"
136 ++ lib.optional stdenv.hostPlatform.isDarwin (
137 if darwinSupport then "--enable-darwin" else "--disable-darwin"
138 )
139 ++ lib.optionals luaSupport [
140 "--with-lua-prefix=${lua}"
141 "--enable-luainterp"
142 ]
143 ++ lib.optionals lua.pkgs.isLuaJIT [
144 "--with-luajit"
145 ]
146 ++ lib.optionals pythonSupport [
147 "--enable-python3interp=yes"
148 "--with-python3-config-dir=${python3}/lib"
149 # Disables Python 2
150 "--disable-pythoninterp"
151 ]
152 ++ lib.optional nlsSupport "--enable-nls"
153 ++ lib.optional perlSupport "--enable-perlinterp"
154 ++ lib.optional rubySupport "--enable-rubyinterp"
155 ++ lib.optional tclSupport "--enable-tclinterp"
156 ++ lib.optional multibyteSupport "--enable-multibyte"
157 ++ lib.optional cscopeSupport "--enable-cscope"
158 ++ lib.optional netbeansSupport "--enable-netbeans"
159 ++ lib.optional ximSupport "--enable-xim"
160 ++ lib.optional sodiumSupport "--enable-sodium";
161
162 nativeBuildInputs = [
163 pkg-config
164 ]
165 ++ lib.optional wrapPythonDrv makeWrapper
166 ++ lib.optional nlsSupport gettext
167 ++ lib.optional perlSupport perl
168 ++ lib.optional (guiSupport == "gtk3") wrapGAppsHook3;
169
170 buildInputs = [
171 ncurses
172 glib
173 ]
174 # All X related dependencies
175 ++ lib.optionals (guiSupport == "gtk2" || guiSupport == "gtk3") [
176 libSM
177 libICE
178 libX11
179 libXext
180 libXpm
181 libXt
182 libXaw
183 libXau
184 libXmu
185 ]
186 ++ lib.optional (guiSupport == "gtk2") gtk2-x11
187 ++ lib.optional (guiSupport == "gtk3") gtk3-x11
188 ++ lib.optional luaSupport lua
189 ++ lib.optional pythonSupport python3
190 ++ lib.optional tclSupport tcl
191 ++ lib.optional rubySupport ruby
192 ++ lib.optional sodiumSupport libsodium;
193
194 # error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes
195 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-fdeclspec";
196
197 preConfigure = lib.optionalString ftNixSupport ''
198 cp ${vimPlugins.vim-nix.src}/ftplugin/nix.vim runtime/ftplugin/nix.vim
199 cp ${vimPlugins.vim-nix.src}/indent/nix.vim runtime/indent/nix.vim
200 '';
201
202 preInstall = ''
203 mkdir -p $out/share/applications $out/share/icons/{hicolor,locolor}/{16x16,32x32,48x48}/apps
204 '';
205
206 postInstall = ''
207 ln -s $out/bin/vim $out/bin/vi
208 ''
209 + lib.optionalString stdenv.hostPlatform.isLinux ''
210 ln -sfn '${nixosRuntimepath}' "$out"/share/vim/vimrc
211 '';
212
213 postFixup =
214 common.postFixup
215 + lib.optionalString wrapPythonDrv ''
216 wrapProgram "$out/bin/vim" --prefix PATH : "${python3}/bin" \
217 --set NIX_PYTHONPATH "${python3}/${python3.sitePackages}"
218 '';
219
220 dontStrip = true;
221}