2007-12-13 10:50:22 +01:00
|
|
|
# TODO tidy up eg The patchelf code is patching gvim even if you don't build it..
|
|
|
|
# but I have gvim with python support now :) - Marc
|
2016-11-07 15:10:32 +01:00
|
|
|
args@{ source ? "default", callPackage, fetchurl, stdenv, ncurses, pkgconfig, gettext
|
2018-07-21 13:48:19 +02:00
|
|
|
, writeText, lib, config, glib, gtk2, gtk3, python, perl, tcl, ruby
|
2015-09-15 06:27:19 +02:00
|
|
|
, libX11, libXext, libSM, libXpm, libXt, libXaw, libXau, libXmu
|
2015-10-20 01:46:23 +02:00
|
|
|
, libICE
|
2018-04-24 22:56:25 +02:00
|
|
|
, vimPlugins
|
vim_configurable: restore ability to override python for modules
It seems as Python will be fetched from $PATH in Vim 8.1:
```
stat("/home/ma27/bin/python", 0x7ffe57a317b0) = -1 ENOENT (No such file or directory)
stat("/run/wrappers/bin/python", 0x7ffe57a317b0) = -1 ENOENT (No such file or directory)
stat("/home/ma27/.nix-profile/bin/python", 0x7ffe57a317b0) = -1 ENOENT (No such file or directory)
stat("/nix/var/nix/profiles/default/bin/python", 0x7ffe57a317b0) = -1 ENOENT (No such file or directory)
stat("/run/current-system/sw/bin/python", {st_mode=S_IFREG|0555, st_size=291, ...}) = 0
readlink("/run/current-system/sw/bin/python", "/nix/store/ggjkqbvwnv7dflkmdgmmp"..., 4096) = 72
```
This breaks in cases where you want to use a modified Python derivation
for the VIM plugins you use in `vim_configurable`:
```
let
vim_configurable' = vim_configurable.override {
# python with modules for ensime
python = python.withPackages (ps: with ps; [ sexpdata websocket_client ]);
};
in
vim_configurable'.customize {
# ...
}
```
With VIM 8.0 this worked perfectly fine, now it's necessary to install
the modified `python` in $PATH to actually use it, otherwise an error
like this arises:
```
[ensime] A dependency is missing, please `pip2 install sexpdata websocket-client` and restart Vim.
Press ENTER or type command to continue
```
However it should be possible to pass the modified Python to the
modules, the easiest workaround is to write a wrapper which prefixes
$PATH to have the Python derivation available.
2018-05-22 14:07:41 +02:00
|
|
|
, makeWrapper
|
2018-08-09 11:11:24 +02:00
|
|
|
, wrapGAppsHook
|
2015-10-20 01:46:23 +02:00
|
|
|
|
|
|
|
# apple frameworks
|
|
|
|
, CoreServices, CoreData, Cocoa, Foundation, libobjc, cf-private
|
|
|
|
|
2018-07-21 13:48:19 +02:00
|
|
|
, features ? "huge" # One of tiny, small, normal, big or huge
|
|
|
|
, wrapPythonDrv ? false
|
|
|
|
, guiSupport ? config.vim.gui or "auto"
|
|
|
|
, luaSupport ? config.vim.lua or true
|
|
|
|
, perlSupport ? config.vim.perl or false # Perl interpreter
|
|
|
|
, pythonSupport ? config.vim.python or true # Python interpreter
|
|
|
|
, rubySupport ? config.vim.ruby or true # Ruby interpreter
|
|
|
|
, nlsSupport ? config.vim.nls or false # Enable NLS (gettext())
|
|
|
|
, tclSupport ? config.vim.tcl or false # Include Tcl interpreter
|
|
|
|
, multibyteSupport ? config.vim.multibyte or false # Enable multibyte editing support
|
|
|
|
, cscopeSupport ? config.vim.cscope or true # Enable cscope interface
|
|
|
|
, netbeansSupport ? config.netbeans or true # Enable NetBeans integration support.
|
|
|
|
, ximSupport ? config.vim.xim or true # less than 15KB, needed for deadkeys
|
|
|
|
# By default, compile with darwin support if we're compiling on darwin, but
|
|
|
|
# allow this to be disabled by setting config.vim.darwin to false
|
|
|
|
, darwinSupport ? stdenv.isDarwin && (config.vim.darwin or true) # Enable Darwin support
|
|
|
|
, ftNixSupport ? config.vim.ftNix or true # Add .nix filetype detection and minimal syntax highlighting support
|
2015-10-20 01:46:23 +02:00
|
|
|
, ... }: with args;
|
2014-06-28 22:34:48 +02:00
|
|
|
|
|
|
|
|
2016-11-07 15:10:32 +01:00
|
|
|
let
|
|
|
|
nixosRuntimepath = writeText "nixos-vimrc" ''
|
2014-07-09 22:01:14 +02:00
|
|
|
set nocompatible
|
|
|
|
syntax on
|
|
|
|
|
2014-06-28 22:34:48 +02:00
|
|
|
function! NixosPluginPath()
|
|
|
|
let seen = {}
|
|
|
|
for p in reverse(split($NIX_PROFILES))
|
|
|
|
for d in split(glob(p . '/share/vim-plugins/*'))
|
|
|
|
let pluginname = substitute(d, ".*/", "", "")
|
|
|
|
if !has_key(seen, pluginname)
|
|
|
|
exec 'set runtimepath^='.d
|
2017-07-14 14:22:36 +02:00
|
|
|
let after = d."/after"
|
|
|
|
if isdirectory(after)
|
|
|
|
exec 'set runtimepath^='.after
|
|
|
|
endif
|
2014-06-28 22:34:48 +02:00
|
|
|
let seen[pluginname] = 1
|
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
endfor
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
execute NixosPluginPath()
|
2014-07-09 21:45:26 +02:00
|
|
|
|
|
|
|
if filereadable("/etc/vimrc")
|
|
|
|
source /etc/vimrc
|
|
|
|
elseif filereadable("/etc/vim/vimrc")
|
|
|
|
source /etc/vim/vimrc
|
|
|
|
endif
|
2014-06-28 22:34:48 +02:00
|
|
|
'';
|
2016-11-07 15:10:32 +01:00
|
|
|
|
|
|
|
common = callPackage ./common.nix {};
|
2007-12-12 08:20:41 +01:00
|
|
|
|
2018-07-21 13:48:19 +02:00
|
|
|
isPython3 = python.isPy3 or false;
|
2008-12-20 02:20:35 +01:00
|
|
|
|
2018-07-21 13:48:19 +02:00
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
|
|
|
|
name = "vim_configurable-${version}";
|
|
|
|
|
|
|
|
inherit (common) version postPatch hardeningDisable enableParallelBuilding meta;
|
2017-02-05 03:29:59 +01:00
|
|
|
|
2018-07-21 13:48:19 +02:00
|
|
|
src = builtins.getAttr source {
|
|
|
|
"default" = common.src; # latest release
|
|
|
|
};
|
|
|
|
|
|
|
|
patches = [ ./cflags-prune.diff ] ++ stdenv.lib.optional ftNixSupport ./ft-nix-support.patch;
|
|
|
|
|
|
|
|
configureFlags = [
|
|
|
|
"--enable-gui=${guiSupport}"
|
|
|
|
"--with-features=${features}"
|
|
|
|
"--disable-xsmp" # XSMP session management
|
|
|
|
"--disable-xsmp_interact" # XSMP interaction
|
|
|
|
"--disable-workshop" # Sun Visual Workshop support
|
|
|
|
"--disable-sniff" # Sniff interface
|
|
|
|
"--disable-hangulinput" # Hangul input support
|
|
|
|
"--disable-fontset" # X fontset output support
|
|
|
|
"--disable-acl" # ACL support
|
|
|
|
"--disable-gpm" # GPM (Linux mouse daemon)
|
|
|
|
"--disable-mzschemeinterp"
|
|
|
|
"--disable-gtk_check"
|
|
|
|
"--disable-gtk2_check"
|
|
|
|
"--disable-gnome_check"
|
|
|
|
"--disable-motif_check"
|
|
|
|
"--disable-athena_check"
|
|
|
|
"--disable-nextaf_check"
|
|
|
|
"--disable-carbon_check"
|
|
|
|
"--disable-gtktest"
|
|
|
|
]
|
|
|
|
++ stdenv.lib.optionals luaSupport [
|
|
|
|
"--with-lua-prefix=${args.lua}"
|
|
|
|
"--enable-luainterp"
|
|
|
|
]
|
|
|
|
++ stdenv.lib.optionals pythonSupport [
|
2018-07-28 00:14:05 +02:00
|
|
|
"--enable-python${if isPython3 then "3" else ""}interp=yes"
|
2018-07-21 13:48:19 +02:00
|
|
|
"--with-python${if isPython3 then "3" else ""}-config-dir=${python}/lib"
|
2018-07-28 00:14:05 +02:00
|
|
|
"--disable-python${if (!isPython3) then "3" else ""}interp"
|
2018-07-21 13:48:19 +02:00
|
|
|
]
|
|
|
|
++ stdenv.lib.optional nlsSupport "--enable-nls"
|
|
|
|
++ stdenv.lib.optional perlSupport "--enable-perlinterp"
|
|
|
|
++ stdenv.lib.optional rubySupport "--enable-rubyinterp"
|
|
|
|
++ stdenv.lib.optional tclSupport "--enable-tclinterp"
|
|
|
|
++ stdenv.lib.optional multibyteSupport "--enable-multibyte"
|
|
|
|
++ stdenv.lib.optional cscopeSupport "--enable-cscope"
|
|
|
|
++ stdenv.lib.optional netbeansSupport "--enable-netbeans"
|
|
|
|
++ stdenv.lib.optional ximSupport "--enable-xim";
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
pkgconfig
|
|
|
|
]
|
|
|
|
++ stdenv.lib.optional wrapPythonDrv makeWrapper
|
|
|
|
++ stdenv.lib.optional nlsSupport gettext
|
|
|
|
++ stdenv.lib.optional perlSupport perl
|
2018-08-09 11:11:24 +02:00
|
|
|
++ stdenv.lib.optional (guiSupport == "gtk3") wrapGAppsHook
|
2018-07-21 13:48:19 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
buildInputs = [ ncurses libX11 libXext libSM libXpm libXt libXaw libXau
|
|
|
|
libXmu glib libICE ]
|
|
|
|
++ (if guiSupport == "gtk3" then [gtk3] else [gtk2])
|
|
|
|
++ stdenv.lib.optionals darwinSupport [ CoreServices CoreData Cocoa Foundation libobjc cf-private ]
|
|
|
|
++ stdenv.lib.optional luaSupport lua
|
|
|
|
++ stdenv.lib.optional pythonSupport python
|
|
|
|
++ stdenv.lib.optional tclSupport tcl
|
|
|
|
++ stdenv.lib.optional rubySupport ruby;
|
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
'' + stdenv.lib.optionalString ftNixSupport ''
|
|
|
|
cp ${vimPlugins.vim-nix.src}/ftplugin/nix.vim runtime/ftplugin/nix.vim
|
|
|
|
cp ${vimPlugins.vim-nix.src}/indent/nix.vim runtime/indent/nix.vim
|
|
|
|
cp ${vimPlugins.vim-nix.src}/syntax/nix.vim runtime/syntax/nix.vim
|
|
|
|
'';
|
|
|
|
|
|
|
|
NIX_LDFLAGS = stdenv.lib.optionalString (darwinSupport && stdenv.isDarwin)
|
|
|
|
"/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation";
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
'' + stdenv.lib.optionalString stdenv.isLinux ''
|
2016-11-07 15:45:48 +01:00
|
|
|
patchelf --set-rpath \
|
|
|
|
"$(patchelf --print-rpath $out/bin/vim):${lib.makeLibraryPath buildInputs}" \
|
|
|
|
"$out"/bin/{vim,gvim}
|
|
|
|
|
|
|
|
ln -sfn '${nixosRuntimepath}' "$out"/share/vim/vimrc
|
2018-07-21 13:48:19 +02:00
|
|
|
'' + stdenv.lib.optionalString wrapPythonDrv ''
|
|
|
|
wrapProgram "$out/bin/vim" --prefix PATH : "${python}/bin"
|
2018-08-11 09:24:45 +02:00
|
|
|
'' + stdenv.lib.optionalString (guiSupport == "gtk3") ''
|
|
|
|
rm "$out/bin/gvim"
|
|
|
|
echo -e '#!${stdenv.shell}\n"'"$out/bin/vim"'" -g "$@"' > "$out/bin/gvim"
|
|
|
|
chmod a+x "$out/bin/gvim"
|
2018-07-21 13:48:19 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
preInstall = ''
|
|
|
|
mkdir -p $out/share/applications $out/share/icons/{hicolor,locolor}/{16x16,32x32,48x48}/apps
|
2013-06-19 04:05:42 +02:00
|
|
|
'';
|
2013-06-13 10:12:12 +02:00
|
|
|
|
|
|
|
dontStrip = 1;
|
2018-07-21 13:48:19 +02:00
|
|
|
}
|