modules: add env option

This commit is contained in:
Gaetan Lepage 2025-03-23 12:27:50 +01:00 committed by Gaétan Lepage
parent f4f4b4975a
commit db01a0dd97
3 changed files with 72 additions and 1 deletions

View file

@ -28,6 +28,26 @@ let
in
{
options = {
env = mkOption {
type =
with types;
lazyAttrsOf (oneOf [
str
path
int
float
]);
description = "Environment variables to set in the neovim wrapper.";
default = { };
example = {
FOO = 1;
PI = 3.14;
BAR_PATH = "/home/me/.local/share/bar";
INFER_MODE = "local";
BAZ_MAX_COUNT = 1000;
};
};
extraPlugins = mkOption {
type = with types; listOf (nullOr (either package pluginWithConfigType));
default = [ ];

View file

@ -339,7 +339,16 @@ in
initSource;
extraWrapperArgs = builtins.concatStringsSep " " (
(optional (
# Setting environment variables in the wrapper
(lib.mapAttrsToList (
name: value:
lib.escapeShellArgs [
"--set"
name
value
]
) config.env)
++ (optional (
config.extraPackages != [ ]
) ''--prefix PATH : "${lib.makeBinPath config.extraPackages}"'')
++ (optional config.wrapRc ''--add-flags -u --add-flags "${initFile}"'')