1{ ripgrep
2, git
3, fzf
4, makeWrapper
5, vim-full
6, vimPlugins
7, fetchFromGitHub
8, lib
9, stdenv
10, formats
11, runCommand
12, spacevim_config ? import ./init.nix
13}:
14
15let
16 format = formats.toml { };
17 vim-customized = vim-full.customize {
18 name = "vim";
19 # Not clear at the moment how to import plugins such that
20 # SpaceVim finds them and does not auto download them to
21 # ~/.cache/vimfiles/repos
22 vimrcConfig.packages.myVimPackage = with vimPlugins; { start = [ ]; };
23 };
24 spacevimdir = runCommand "SpaceVim.d" { } ''
25 mkdir -p $out
26 cp ${format.generate "init.toml" spacevim_config} $out/init.toml
27 '';
28in
29stdenv.mkDerivation rec {
30 pname = "spacevim";
31 version = "1.8.0";
32 src = fetchFromGitHub {
33 owner = "SpaceVim";
34 repo = "SpaceVim";
35 rev = "v${version}";
36 sha256 = "sha256:11snnh5q47nqhzjb9qya6hpnmlzc060958whqvqrh4hc7gnlnqp8";
37 };
38
39 nativeBuildInputs = [ makeWrapper vim-customized ];
40 buildInputs = [ vim-customized ];
41
42 buildPhase = ''
43 runHook preBuild
44 # generate the helptags
45 vim -u NONE -c "helptags $(pwd)/doc" -c q
46 runHook postBuild
47 '';
48
49 patches = [
50 # Don't generate helptags at runtime into read-only $SPACEVIMDIR
51 ./helptags.patch
52 ];
53
54 installPhase = ''
55 runHook preInstall
56 mkdir -p $out/bin
57
58 cp -r $(pwd) $out/SpaceVim
59
60 # trailing slash very important for SPACEVIMDIR
61 makeWrapper "${vim-customized}/bin/vim" "$out/bin/spacevim" \
62 --add-flags "-u $out/SpaceVim/vimrc" --set SPACEVIMDIR "${spacevimdir}/" \
63 --prefix PATH : ${lib.makeBinPath [ fzf git ripgrep]}
64 runHook postInstall
65 '';
66
67 meta = with lib; {
68 description = "Modern Vim distribution";
69 longDescription = ''
70 SpaceVim is a distribution of the Vim editor that’s inspired by spacemacs.
71 '';
72 homepage = "https://spacevim.org/";
73 license = licenses.gpl3Plus;
74 maintainers = [ maintainers.fzakaria ];
75 platforms = platforms.all;
76 };
77}