Jelajahi Sumber

nixpkgs/neovim: add minimal configuration

Thomas Dy 1 tahun lalu
induk
melakukan
239c9b08dc
2 mengubah file dengan 58 tambahan dan 43 penghapusan
  1. 1 0
      .config/nixpkgs/neovim/flake.nix
  2. 57 43
      .config/nixpkgs/neovim/neovim.nix

+ 1 - 0
.config/nixpkgs/neovim/flake.nix

@@ -31,6 +31,7 @@
         packages.neovim = pkgs.callPackage ./neovim.nix {};
         packages.neovim-with-playground = pkgs.callPackage ./neovim.nix { withPlayground = true; };
         packages.neovim-with-luadev = pkgs.callPackage ./neovim.nix { withLuadev = true; };
+        packages.neovim-minimal = (pkgs.callPackage ./neovim.nix {}).minimal;
         packages.default = self.packages.${system}.neovim;
       }
     );

+ 57 - 43
.config/nixpkgs/neovim/neovim.nix

@@ -94,20 +94,62 @@ let
     ++ [
       extra-treesitter-textobjects
     ];
-in
-stdenv.mkDerivation {
-  pname = "nvim";
-  version = neovim-unwrapped.version;
 
-  initVim = ''
-    let g:loaded_python3_provider = 0
-    let g:loaded_ruby_provider = 0
-    let g:loaded_node_provider = 0
-    let g:loaded_perl_provider = 0
+  generic = { initText ? "", enabledPlugins ? [], passthru ? {} }: stdenv.mkDerivation {
+    pname = "nvim";
+    version = neovim-unwrapped.version;
+
+    initVim = ''
+      let g:loaded_python3_provider = 0
+      let g:loaded_ruby_provider = 0
+      let g:loaded_node_provider = 0
+      let g:loaded_perl_provider = 0
+
+      set runtimepath^=${placeholder "out"}/lib
+      set packpath^=${placeholder "out"}/lib
+
+      ${initText}
+    '';
+
+    passAsFile = [ "initVim" ];
+
+    nativeBuildInputs = [ makeWrapper ];
+
+    unpackPhase = ":";
+
+    buildPhase = ''
+      # build pack / runtime dir
+      mkdir -p lib/pack/nixpkgs/start
+      ${lib.concatMapStringsSep "\n" (p: ''
+        ln -s "${p}" "lib/pack/nixpkgs/start/${lib.getName p}"
+      '') enabledPlugins}
+
+      # create config file
+      mkdir etc
+      cp "$initVimPath" etc/init.vim
+
+      # symlink in man pages
+      mkdir -p share
+      ln -s ${neovim-unwrapped}/share/man share/man
+
+      # make bin
+      mkdir bin
+      makeWrapper ${neovim-unwrapped}/bin/nvim bin/nvim \
+        --prefix PATH : ${lib.makeBinPath extraPath} \
+        --add-flags -u \
+        --add-flags $out/etc/init.vim
+    '';
 
-    set runtimepath^=${placeholder "out"}/lib
-    set packpath^=${placeholder "out"}/lib
+    inherit passthru;
 
+    installPhase = ''
+      mkdir $out
+      cp -r * $out
+    '';
+  };
+in
+generic {
+  initText = ''
     source ${./settings.lua}
     source ${./plugins.lua}
     source ${./mappings.lua}
@@ -121,37 +163,9 @@ stdenv.mkDerivation {
     source ${./luadev.lua}
   '';
 
-  passAsFile = [ "initVim" ];
-
-  nativeBuildInputs = [ makeWrapper ];
-
-  unpackPhase = ":";
-
-  buildPhase = ''
-    # build pack / runtime dir
-    mkdir -p lib/pack/nixpkgs/start
-    ${lib.concatMapStringsSep "\n" (p: ''
-      ln -s "${p}" "lib/pack/nixpkgs/start/${lib.getName p}"
-    '') plugins}
+  enabledPlugins = plugins;
 
-    # create config file
-    mkdir etc
-    cp "$initVimPath" etc/init.vim
-
-    # symlink in man pages
-    mkdir -p share
-    ln -s ${neovim-unwrapped}/share/man share/man
-
-    # make bin
-    mkdir bin
-    makeWrapper ${neovim-unwrapped}/bin/nvim bin/nvim \
-      --prefix PATH : ${lib.makeBinPath extraPath} \
-      --add-flags -u \
-      --add-flags $out/etc/init.vim
-  '';
-
-  installPhase = ''
-    mkdir $out
-    cp -r * $out
-  '';
+  passthru = {
+    minimal = generic {};
+  };
 }