I used home-manager to install neovim from github (master branch for version 0.5.x). I’m running Arch Linux as the base OS.
home.nix (click to expand)
{ config, pkgs, ... }:
let
custom.neovim = pkgs.neovim-unwrapped.overrideAttrs (oa: {
version = "master";
src = builtins.fetchTarball {
url = "https://github.com/neovim/neovim/archive/390fed3248ff8cd67849891bbf1f214cf17bb952.tar.gz";
sha256 = "09g9655mw0m9wj3k924jpk661gli3m24qzvh3j9j6j7x8lkc5ch2";
};
buildInputs = oa.buildInputs ++ (with pkgs; [
tree-sitter
]);
cmakeFlags = oa.cmakeFlags ++ [
"-DUSE_BUNDLED=OFF"
];
});
in
{
programs.home-manager.enable = true;
home.username = "boxofrox";
home.homeDirectory = "/home/boxofrox";
home.stateVersion = "20.09";
home.packages = with pkgs; [];
programs.neovim = {
enable = true;
package = custom.neovim;
withRuby = true;
extraPackages = with pkgs; [
neovim-remote
];
extraConfig = ''
call plug#begin('~/.config/nvim/plugged')
Plug '~/files/development/vim-timecard'
call plug#end()
'';
};
}
I wrote a ruby plugin for neovim (vim-timecard
) to document the time I spend on tasks, and this plugin uses the hamster ~>2.0
gem for immutable data structures. I cannot figure out how to install hamster
, such that, when I start nvim
, my plugin doesn’t complain that it is unable to load hamster
.
Any assistance would be appreciated.
I find it odd that the makeNeovimConfig
[1] in nixpkgs allows me to specify python packages (extraPython3Packages
) that are required, but doesn’t offer the same for ruby. ?_?
Things I’ve tried.
Install hamster using system’s default gem binary
I have the ruby v3.0.0 package provided by Arch Linux installed. It configures the gem tool to install gems under ~/.gem
. I ran…
$ gem install hamster
… and promptly installed hamster 3.0
.
vim-timecard
cannot find hamster
when neovim starts.
I can see hamster 3.0.0
in the gem list
output.
Install hamster 2.0 using system’s default gem binary
I ran gem install 'hamster:~>2.0'
.
gem list
reports both 3.0 and 2.0 versions of hamster
(no idea how that works when my ruby plugin cannot import libraries by version, to my knowledge).
nvim
starts and vim-timecard
cannot load hamster
.
Review neovim ruby environment.
Start neovim. Run :ruby print ENV['PATH']
.
/nix/store/yw25krsaa2kckpf02xcg96r0hs5bwxrz-neovim-ruby-env/lib/ruby/gems/2.7.0/bin
:/home/boxofrox/.nix-profile/bin
:/usr/bin
:/nix/store/yw25krsaa2kckpf02xcg96r0hs5bwxrz-neovim-ruby-env/bin
:/nix/store/1nacslwmmvym8pb3pngfd3lqpcyx9gsp-neovim-remote-2.4.0/bin
Then run :! /nix/store/yw25krsaa2kckpf02xcg96r0hs5bwxrz-neovim-ruby-env/bin/gem env
.
gem env output (click to expand)
RubyGems Environment:
- RUBYGEMS VERSION: 3.2.16
- RUBY VERSION: 2.7.3 (2021-04-05 patchlevel 183) [x86_64-linux]
- INSTALLATION DIRECTORY: /nix/store/yw25krsaa2kckpf02xcg96r0hs5bwxrz-neovim-ruby-env/lib/ruby/gems/2.7.0
- USER INSTALLATION DIRECTORY: /home/boxofrox/.gem/ruby/2.7.0
- RUBY EXECUTABLE: /nix/store/pdbpgvsq90hq0c0fkz5xz01bczr74aqx-ruby-2.7.3/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /nix/store/yw25krsaa2kckpf02xcg96r0hs5bwxrz-neovim-ruby-env/lib/ruby/gems/2.7.0/bin
- SPEC CACHE DIRECTORY: /home/boxofrox/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /nix/store/pdbpgvsq90hq0c0fkz5xz01bczr74aqx-ruby-2.7.3/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /nix/store/yw25krsaa2kckpf02xcg96r0hs5bwxrz-neovim-ruby-env/lib/ruby/gems/2.7.0
- /home/boxofrox/.gem/ruby/2.7.0
- /nix/store/pdbpgvsq90hq0c0fkz5xz01bczr74aqx-ruby-2.7.3/lib/ruby/gems/2.7.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /home/boxofrox/.nix-profile/bin
- /home/boxofrox/.nix-profile/bin
- /home/boxofrox/.nix-profile/bin
- /usr/bin
- /nix/store/yw25krsaa2kckpf02xcg96r0hs5bwxrz-neovim-ruby-env/bin
- /nix/store/1nacslwmmvym8pb3pngfd3lqpcyx9gsp-neovim-remote-2.4.0/bin
Ok. Seems the gem needs to install under ~/.gem/ruby/2.7.0
, instead of ~/.gem/ruby/3.0.0
.
Install hamster gem using neovim-ruby-env
Install gem with: /nix/store/yw25krsaa2kckpf02xcg96r0hs5bwxrz-neovim-ruby-env/bin/gem install 'hamster:~>2.0'
Verify gem installed with: /nix/store/yw25krsaa2kckpf02xcg96r0hs5bwxrz-neovim-ruby-env/bin/gem list
. Reports hamster 2.0.0
is installed as a local gem.
Run nvim
, and vim-timecard
cannot load hamster
.
Other notes
In neovim, :ruby print ENV.keys
reports that GEM_HOME
is defined, but not GEM_PATH
. GEM_HOME
points to a single path in the nix store (presumably created by the bundlerEnv
in the neovim package file). I can only assume at this point that the neovim-ruby-env is not looking in ~/.gem/
for locally installed gems.