From 2b6f694b48f43bbd89dcc21e8aa7aa676eb18eb8 Mon Sep 17 00:00:00 2001 From: sportshead Date: Sun, 8 Jun 2025 13:14:17 +0100 Subject: [PATCH] output: add extraPackagesAfter option Allow users to add packages to the end of `PATH` in the neovim wrapper. This is useful for LSP versions that might need to be overriden based on the environment, e.g. `haskell-language-server` versions provided by a project's devshell. --- modules/output.nix | 9 ++++++++- modules/top-level/output.nix | 3 +++ tests/test-sources/modules/output.nix | 12 ++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/modules/output.nix b/modules/output.nix index 92f913e3..172ff283 100644 --- a/modules/output.nix +++ b/modules/output.nix @@ -58,7 +58,14 @@ in extraPackages = mkOption { type = with types; listOf (nullOr package); default = [ ]; - description = "Extra packages to be made available to neovim"; + description = "Extra packages to be made available to neovim, added to the start of `PATH`"; + apply = builtins.filter (p: p != null); + }; + + extraPackagesAfter = mkOption { + type = with types; listOf (nullOr package); + default = [ ]; + description = "Extra packages to be made available to neovim, added to the end of `PATH`"; apply = builtins.filter (p: p != null); }; diff --git a/modules/top-level/output.nix b/modules/top-level/output.nix index f2b8e25a..87b93ff6 100644 --- a/modules/top-level/output.nix +++ b/modules/top-level/output.nix @@ -241,6 +241,9 @@ in ++ (optional ( config.extraPackages != [ ] ) ''--prefix PATH : "${lib.makeBinPath config.extraPackages}"'') + ++ (optional ( + config.extraPackagesAfter != [ ] + ) ''--suffix PATH : "${lib.makeBinPath config.extraPackagesAfter}"'') ++ (optional config.wrapRc ''--add-flags -u --add-flags "${initFile}"'') ); diff --git a/tests/test-sources/modules/output.nix b/tests/test-sources/modules/output.nix index d2444280..d45acb89 100644 --- a/tests/test-sources/modules/output.nix +++ b/tests/test-sources/modules/output.nix @@ -149,4 +149,16 @@ end ''; }; + + extraPackagesAfter = + { pkgs, ... }: + { + extraPackagesAfter = [ pkgs.hello ]; + + extraConfigLua = '' + if vim.fn.executable("hello") ~= 1 then + print("Unable to find hello package.") + end + ''; + }; }