about summary refs log tree commit diff
path: root/pkgs/misc/vim-plugins
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2018-02-07 15:27:05 +0100
committerMaximilian Bosch <maximilian@mbosch.me>2018-02-07 16:57:40 +0100
commit8e70725077f750d8cc46611d6427dd0aa85a7e6e (patch)
treee931f763be9b8cdf8d9a0cb264b6eac468c550d0 /pkgs/misc/vim-plugins
parent5e8ae8d5975ee93ce9bbf6c536591037cd518a66 (diff)
downloadnixlib-8e70725077f750d8cc46611d6427dd0aa85a7e6e.tar
nixlib-8e70725077f750d8cc46611d6427dd0aa85a7e6e.tar.gz
nixlib-8e70725077f750d8cc46611d6427dd0aa85a7e6e.tar.bz2
nixlib-8e70725077f750d8cc46611d6427dd0aa85a7e6e.tar.lz
nixlib-8e70725077f750d8cc46611d6427dd0aa85a7e6e.tar.xz
nixlib-8e70725077f750d8cc46611d6427dd0aa85a7e6e.tar.zst
nixlib-8e70725077f750d8cc46611d6427dd0aa85a7e6e.zip
vim_configurable: enable overrides
Sometimes it's needed to override parts of `vim_configurable`, for
instance when using ENSIME (http://ensime.github.io/), in this case you
need a Python interpreter and the modules `sexpdata` and
`websocket_client`.

However overriding `vim_configurable` is quite hard as we run
`vimUtils.makeCustomizable` over the default comming from
`configurable.nix`. Therefore it's necessary to copy the code from
`all-packages.nix` and alter the parts you need: https://nixos.org/nix-dev/2017-April/023364.html

In order to simplify overriding `vim_configurable` I added an
`override` and an `overrideAttrs` function to `vimutils.makeCustomizable`
to ensure that the customization capabilities won't be lost after
altering the derivation.

Now it's possible to write expressions like this without evaluation
failures:

```
with pkgs;

let
  vimPy3 = vim_configurable.override {
    python = python3;
  };
in vimPy3.customize { ... }
```
Diffstat (limited to 'pkgs/misc/vim-plugins')
-rw-r--r--pkgs/misc/vim-plugins/vim-utils.nix5
1 files changed, 4 insertions, 1 deletions
diff --git a/pkgs/misc/vim-plugins/vim-utils.nix b/pkgs/misc/vim-plugins/vim-utils.nix
index 23749fd4ce60..e11419846aeb 100644
--- a/pkgs/misc/vim-plugins/vim-utils.nix
+++ b/pkgs/misc/vim-plugins/vim-utils.nix
@@ -325,11 +325,14 @@ rec {
 
   # add a customize option to a vim derivation
   makeCustomizable = vim: vim // {
-    customize = {name, vimrcConfig}: vimWithRC {
+    customize = { name, vimrcConfig }: vimWithRC {
       vimExecutable = "${vim}/bin/vim";
       inherit name;
       vimrcFile = vimrcFile vimrcConfig;
     };
+
+    override = f: makeCustomizable (vim.override f);
+    overrideAttrs = f: makeCustomizable (vim.overrideAttrs f);
   };
 
   pluginnames2Nix = {name, namefiles} : vim_configurable.customize {