Help wanted in building a vim plugin (`vim-iced`)

Hi all. I built a nix package for a vim-plugin vim-iced (GitHub - liquidz/vim-iced: Clojure Interactive Development Environment for Vim8/Neovim), using pkgs.vimUtils.buildVimPlugin. The derivation follows:

  vim-iced = self.vimUtils.buildVimPlugin {
    name = "vim-iced";
    src = self.fetchFromGitHub {
      owner = "liquidz";
      repo = "vim-iced";
      rev = "3.6.2";
      sha256 = "1klvq511zc1y8rbjizhc3m0hx3a0ydcjv7wz1s74jx8vnfw24w5n";
    neovim = super.neovim.override {
      configure = {
        packages.myVimPackage = with pkgs.vimPlugins; {
          start = [ vim-iced fzf-vim];

The basic features of the plugin work as intended. As an extra feature, this plug-in also provides an iced binary. Reference from vim-iced

2.1.2. iced command

iced is a utility command to make you easy to use vim-iced, and it comes with vim-iced. Setup is easy, just add the bin directory under the installed vim-iced directory to $PATH environmental variable. With above vim-plug setting, ~/.vim/plugged/vim-iced/bin is the directory to add to $PATH.

# For bash or zsh
$ export PATH=$PATH:~/.vim/plugged/vim-iced/bin

My derivation does not expose that automatically. The installed derivation does provide the binary in a working condition:

>> find /nix/store -name 'vim-iced'


>> ls -l /nix/store/<hash>-vim-pack-dir/pack/myVimPackage/start/vim-iced/bin/
total 20
-r-xr-xr-x 1 jayesh admin 14511 Jan  1  1970 iced
-r--r--r-- 1 jayesh admin    64 Jan  1  1970 iced.cmd


>> /nix/store/<hash>-vim-pack-dir/pack/myVimPackage/start/vim-iced/bin/iced version

Can anyone guide me how I can expose this iced binary to the shell?

1 Like

I managed to solve this by building another derivation on top of vim-iced plugin derivation:

{ vim-iced, stdenv }:

# adapted from:
# Like vim-iced, vimacs plugin also provides a binary (bin/vim) which needs to be exposed to $PATH explicitly.

# In Nix, ~/.nix-profile/bin (which itself is a symlink that points to the current Nix profile) is exposed to $PATH, and all the binaries in the `bin` dir of the installed derivations of the current profile are symlinked inside ~/.nix-profile/bin.
# The problem is a derivation's `bin` is symlinked to ~/.nix-profile only if the derivation is installed directly (and not indirectly like vim-iced, which is handled by neovim).

# The solution for vimacs is to have two derivations:
# vimPlugins.vimacs, which acts as the actual vim plugin, and
# vimacs, which links to the content of `vimPlugins.vimacs` so as not to duplicate them, and then exposes `vimacs` binary within to $PATH.

# This derivation follows the same approach: expose the `iced` binary from the `vim-iced` plugin derivation by symlinking to the full contentof `vim-iced`. Symlinking to just `bin/iced` raises errors while invoking `iced repl`. So better safe than sorry.

stdenv.mkDerivation rec {
  pname = "iced-repl";
  version = vim-iced.version;
  buildInputs = [ vim-iced ];
  buildCommand = ''
    ln -s "${vim-iced}"/share/vim-plugins/vim-iced $out

Relevant files:

I am not sure if this is the correct approach, but it works for me for now.

1 Like

Scratch the last comment completely (I cannot edit it anymore).

A much simpler solution is to install vim-iced BOTH as a:

  • vimPlugin, in order to use the plugin features from vim
  • standalone package, so that Nix symlinks the bin/iced binary to ~/.nix-profile/bin without extra efforts on our part. This redundant installation does not affect the functions of the vimPlugin installation.

Isn’t the “bin” directory too deep in the path for nix to add it to the PATH? I think nix only adds bin directories immediately after the output path (like /nix/store/6n1shhsf3ryn7sm81ih11gfrrsq0hx41-vimplugin-vim-iced/bin, as opposed to /nix/store/6n1shhsf3ryn7sm81ih11gfrrsq0hx41-vimplugin-vim-iced/share/vim-plugins/vim-iced/bin).

I tried adding it as a system package but iced command still couldn’t be found.

jayesh | ~/nix-config  
=> iced
-bash: /Users/jayesh/.nix-profile/bin/iced: No such file or directory

jayesh | ~/nix-config  
=> nix-env -iA nixpkgs.vim-iced
installing 'vimplugin-vim-iced-3.6.2'

jayesh | ~/nix-config  
=> nix-env -q

jayesh | ~/nix-config  
=> iced version

jayesh | ~/nix-config  
=> which iced

jayesh | ~/nix-config  
=> nix-env -e vimplugin-vim-iced 
uninstalling 'vimplugin-vim-iced-3.6.2'

jayesh | ~/nix-config  
=> iced
-bash: /Users/jayesh/.nix-profile/bin/iced: No such file or directory

Installing it as a standalone package works here.

GitHub - liquidz/vim-iced: Clojure Interactive Development Environment for Vim8/Neovim lists bin at its root. So nix would also put bin at root of the derivation IF vim-iced is installed as a standalone package.

1 Like