1 { source ? "default", callPackage, lib, stdenv, ncurses, pkg-config, gettext
2 , writeText, config, glib, gtk2-x11, gtk3-x11, lua, python3, perl, tcl, ruby
3 , libX11, libXext, libSM, libXpm, libXt, libXaw, libXau, libXmu, libsodium
10 , CoreServices, CoreData, Cocoa, Foundation, libobjc
12 , features ? "huge" # One of tiny, small, normal, big or huge
13 , wrapPythonDrv ? false
14 , guiSupport ? config.vim.gui or (if stdenv.hostPlatform.isDarwin then "gtk2" else "gtk3")
15 , luaSupport ? config.vim.lua or true
16 , perlSupport ? config.vim.perl or false # Perl interpreter
17 , pythonSupport ? config.vim.python or true # Python interpreter
18 , rubySupport ? config.vim.ruby or true # Ruby interpreter
19 , nlsSupport ? config.vim.nls or false # Enable NLS (gettext())
20 , tclSupport ? config.vim.tcl or false # Include Tcl interpreter
21 , multibyteSupport ? config.vim.multibyte or false # Enable multibyte editing support
22 , cscopeSupport ? config.vim.cscope or true # Enable cscope interface
23 , netbeansSupport ? config.netbeans or true # Enable NetBeans integration support.
24 , ximSupport ? config.vim.xim or true # less than 15KB, needed for deadkeys
25 , darwinSupport ? config.vim.darwin or false # Enable Darwin support
26 , ftNixSupport ? config.vim.ftNix or true # Add nix indentation support from vim-nix (not needed for basic syntax highlighting)
27 , sodiumSupport ? config.vim.sodium or true # Enable sodium based encryption
32 nixosRuntimepath = writeText "nixos-vimrc" ''
36 function! NixosPluginPath()
38 for p in reverse(split($NIX_PROFILES))
39 for d in split(glob(p . '/share/vim-plugins/*'))
40 let pluginname = substitute(d, ".*/", "", "")
41 if !has_key(seen, pluginname)
42 exec 'set runtimepath^='.d
43 let after = d."/after"
45 exec 'set runtimepath^='.after
47 let seen[pluginname] = 1
53 execute NixosPluginPath()
55 if filereadable("/etc/vimrc")
57 elseif filereadable("/etc/vim/vimrc")
62 common = callPackage ./common.nix {};
64 in stdenv.mkDerivation {
68 inherit (common) version outputs postPatch hardeningDisable enableParallelBuilding meta;
70 src = builtins.getAttr source {
71 default = common.src; # latest release
74 patches = [ ./cflags-prune.diff ];
77 "--with-features=${features}"
78 "--disable-xsmp" # XSMP session management
79 "--disable-xsmp_interact" # XSMP interaction
80 "--disable-workshop" # Sun Visual Workshop support
81 "--disable-sniff" # Sniff interface
82 "--disable-hangulinput" # Hangul input support
83 "--disable-fontset" # X fontset output support
84 "--disable-acl" # ACL support
85 "--disable-gpm" # GPM (Linux mouse daemon)
86 "--disable-mzschemeinterp"
88 "--disable-gtk2_check"
89 "--disable-gnome_check"
90 "--disable-motif_check"
91 "--disable-athena_check"
92 "--disable-nextaf_check"
93 "--disable-carbon_check"
95 ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
96 "vim_cv_toupper_broken=no"
99 "vim_cv_tgetent=zero" # it does on native anyway
100 "vim_cv_tty_group=tty"
101 "vim_cv_tty_mode=0660"
102 "vim_cv_getcwd_broken=no"
103 "vim_cv_stat_ignores_slash=yes"
104 "vim_cv_memmove_handles_overlap=yes"
106 ++ lib.optional (guiSupport == "gtk2" || guiSupport == "gtk3") "--enable-gui=${guiSupport}"
107 ++ lib.optional stdenv.hostPlatform.isDarwin
108 (if darwinSupport then "--enable-darwin" else "--disable-darwin")
109 ++ lib.optionals luaSupport [
110 "--with-lua-prefix=${lua}"
112 ] ++ lib.optionals lua.pkgs.isLuaJIT [
115 ++ lib.optionals pythonSupport [
116 "--enable-python3interp=yes"
117 "--with-python3-config-dir=${python3}/lib"
119 "--disable-pythoninterp"
121 ++ lib.optional nlsSupport "--enable-nls"
122 ++ lib.optional perlSupport "--enable-perlinterp"
123 ++ lib.optional rubySupport "--enable-rubyinterp"
124 ++ lib.optional tclSupport "--enable-tclinterp"
125 ++ lib.optional multibyteSupport "--enable-multibyte"
126 ++ lib.optional cscopeSupport "--enable-cscope"
127 ++ lib.optional netbeansSupport "--enable-netbeans"
128 ++ lib.optional ximSupport "--enable-xim"
129 ++ lib.optional sodiumSupport "--enable-sodium";
131 nativeBuildInputs = [
134 ++ lib.optional wrapPythonDrv makeWrapper
135 ++ lib.optional nlsSupport gettext
136 ++ lib.optional perlSupport perl
137 ++ lib.optional (guiSupport == "gtk3") wrapGAppsHook3
144 # All X related dependencies
145 ++ lib.optionals (guiSupport == "gtk2" || guiSupport == "gtk3") [
156 ++ lib.optional (guiSupport == "gtk2") gtk2-x11
157 ++ lib.optional (guiSupport == "gtk3") gtk3-x11
158 ++ lib.optionals darwinSupport [ CoreServices CoreData Cocoa Foundation libobjc ]
159 ++ lib.optional luaSupport lua
160 ++ lib.optional pythonSupport python3
161 ++ lib.optional tclSupport tcl
162 ++ lib.optional rubySupport ruby
163 ++ lib.optional sodiumSupport libsodium;
165 # error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes
166 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-fdeclspec";
168 preConfigure = lib.optionalString ftNixSupport ''
169 cp ${vimPlugins.vim-nix.src}/ftplugin/nix.vim runtime/ftplugin/nix.vim
170 cp ${vimPlugins.vim-nix.src}/indent/nix.vim runtime/indent/nix.vim
174 mkdir -p $out/share/applications $out/share/icons/{hicolor,locolor}/{16x16,32x32,48x48}/apps
178 ln -s $out/bin/vim $out/bin/vi
179 '' + lib.optionalString stdenv.hostPlatform.isLinux ''
180 ln -sfn '${nixosRuntimepath}' "$out"/share/vim/vimrc
183 postFixup = common.postFixup + lib.optionalString wrapPythonDrv ''
184 wrapProgram "$out/bin/vim" --prefix PATH : "${python3}/bin" \
185 --set NIX_PYTHONPATH "${python3}/${python3.sitePackages}"