summary refs log tree commit diff
path: root/pkgs/applications/editors/vim
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2018-05-22 14:07:41 +0200
committerMaximilian Bosch <maximilian@mbosch.me>2018-05-30 09:16:55 +0200
commitf43446c9ca382e8d50901b409080171a2087f630 (patch)
tree10155cdbb7b1543039965689369957ce717b5358 /pkgs/applications/editors/vim
parent57d591ec7f386453444f0b2e9765b336cea5f95d (diff)
downloadnixlib-f43446c9ca382e8d50901b409080171a2087f630.tar
nixlib-f43446c9ca382e8d50901b409080171a2087f630.tar.gz
nixlib-f43446c9ca382e8d50901b409080171a2087f630.tar.bz2
nixlib-f43446c9ca382e8d50901b409080171a2087f630.tar.lz
nixlib-f43446c9ca382e8d50901b409080171a2087f630.tar.xz
nixlib-f43446c9ca382e8d50901b409080171a2087f630.tar.zst
nixlib-f43446c9ca382e8d50901b409080171a2087f630.zip
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.
Diffstat (limited to 'pkgs/applications/editors/vim')
-rw-r--r--pkgs/applications/editors/vim/configurable.nix8
1 files changed, 8 insertions, 0 deletions
diff --git a/pkgs/applications/editors/vim/configurable.nix b/pkgs/applications/editors/vim/configurable.nix
index 9ffa31f2f2e0..ad04cab62f51 100644
--- a/pkgs/applications/editors/vim/configurable.nix
+++ b/pkgs/applications/editors/vim/configurable.nix
@@ -5,10 +5,13 @@ args@{ source ? "default", callPackage, fetchurl, stdenv, ncurses, pkgconfig, ge
 , libX11, libXext, libSM, libXpm, libXt, libXaw, libXau, libXmu
 , libICE
 , vimPlugins
+, makeWrapper
 
 # apple frameworks
 , CoreServices, CoreData, Cocoa, Foundation, libobjc, cf-private
 
+, wrapPythonDrv ? false
+
 , ... }: with args;
 
 
@@ -106,6 +109,11 @@ composableDerivation {
         feat = "python${if python ? isPy3 then "3" else ""}interp";
         enable = {
           buildInputs = [ python ];
+        } // lib.optionalAttrs wrapPythonDrv {
+          nativeBuildInputs = [ makeWrapper ];
+          postInstall = ''
+            wrapProgram "$out/bin/vim" --prefix PATH : "${python}/bin"
+          '';
         } // lib.optionalAttrs stdenv.isDarwin {
           configureFlags
             = [ "--enable-python${if python ? isPy3 then "3" else ""}interp=yes"