From 2f4dcafaa3fed57dab3bd55b9a879e4826c9659b Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 21 Apr 2024 03:21:48 +0300 Subject: [PATCH] modules: pass `extraPackages` to wrapper `PATH` --- modules/default.nix | 21 +++++++++++++++++---- modules/wrapper/build/options.nix | 10 ++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/modules/default.nix b/modules/default.nix index f840334..aaedd42 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -10,7 +10,8 @@ inputs: { inherit (pkgs) wrapNeovimUnstable vimPlugins; inherit (pkgs.vimUtils) buildVimPlugin; inherit (pkgs.neovimUtils) makeNeovimConfig; - inherit (lib.lists) concatLists; + inherit (lib.strings) makeBinPath escapeShellArgs concatStringsSep; + inherit (lib.lists) concatLists optional; inherit (lib.attrsets) recursiveUpdate; inherit (lib.asserts) assertMsg; @@ -82,11 +83,19 @@ inputs: { plugins = builtStartPlugins ++ builtOptPlugins; + # additional Lua and Python3 packages, mapped to their respective functions + # to conform to the format makeNeovimConfig expects. end user should + # only ever need to pass a list of packages, which are modified + # here extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages; extraPython3Packages = ps: map (x: ps.${x}) vimOptions.python3Packages; - # wrap user's desired neovim package using the neovim wrapper from nixpkgs - # the wrapper takes the following arguments: + extraWrapperArgs = + concatStringsSep " " (optional (vimOptions.extraPackages != []) ''--prefix PATH : "${makeBinPath vimOptions.extraPackages}"''); + + # wrap user's desired neovim package with the desired neovim configuration + # using wrapNeovimUnstable and makeNeovimConfig from nixpkgs. + # the makeNeovimConfig function takes the following arguments: # - withPython (bool) # - extraPython3Packages (lambda) # - withNodeJs (bool) @@ -95,10 +104,14 @@ inputs: { # - plugins (list) # - customRC (string) # and returns the wrapped package - neovim-wrapped = wrapNeovimUnstable vimOptions.package (makeNeovimConfig { + neovimConfigured = makeNeovimConfig { inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3; inherit plugins extraLuaPackages extraPython3Packages; customRC = vimOptions.builtConfigRC; + }; + + neovim-wrapped = wrapNeovimUnstable vimOptions.package (recursiveUpdate neovimConfigured { + wrapperArgs = escapeShellArgs neovimConfigured.wrapperArgs + " " + extraWrapperArgs; }); in { inherit (module) options config; diff --git a/modules/wrapper/build/options.nix b/modules/wrapper/build/options.nix index 0004bda..0711046 100644 --- a/modules/wrapper/build/options.nix +++ b/modules/wrapper/build/options.nix @@ -94,6 +94,16 @@ in { ''; }; + extraPackages = mkOption { + type = listOf package; + default = []; + example = literalExpression ''[pkgs.fzf pkgs.ripgrep]''; + description = '' + List of additional packages to make available to the Neovim + wrapper. + ''; + }; + # this defaults to `true` in the wrapper # and since we passs this value to the wrapper # with an inherit, it should be `true` here as well