diff --git a/plugins/default.nix b/plugins/default.nix index c632e132..10803ca9 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -120,6 +120,7 @@ ./utils/neogen.nix ./utils/notify.nix ./utils/netman.nix + ./utils/nix-develop.nix ./utils/nvim-autopairs.nix ./utils/nvim-bqf.nix ./utils/nvim-colorizer.nix diff --git a/plugins/utils/nix-develop.nix b/plugins/utils/nix-develop.nix new file mode 100644 index 00000000..04e089b0 --- /dev/null +++ b/plugins/utils/nix-develop.nix @@ -0,0 +1,43 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.plugins.nix-develop; + helpers = import ../helpers.nix {inherit lib;}; +in { + options.plugins.nix-develop = + helpers.extraOptionsOptions + // { + enable = mkEnableOption "nix-develop.nvim"; + + package = helpers.mkPackageOption "nix-develop.nvim" pkgs.vimPlugins.nix-develop-nvim; + + ignoredVariables = mkOption { + type = types.attrsOf types.bool; + default = {}; + }; + + separatedVariables = mkOption { + type = types.attrsOf types.str; + default = {}; + }; + }; + + config = mkIf cfg.enable { + extraPlugins = [cfg.package]; + extraConfigLua = '' + local __ignored_variables = ${helpers.toLuaObject cfg.ignoredVariables} + for ignoredVariable, shouldIgnore in ipairs(__ignored_variables) do + require("nix-develop").ignored_variables[ignoredVariable] = shouldIgnore + end + + local __separated_variables = ${helpers.toLuaObject cfg.separatedVariables} + for variable, separator in ipairs(__separated_variables) do + require("nix-develop").separated_variables[variable] = separator + end + ''; + }; +} diff --git a/tests/test-sources/plugins/utils/nix-develop.nix b/tests/test-sources/plugins/utils/nix-develop.nix new file mode 100644 index 00000000..e4bce31e --- /dev/null +++ b/tests/test-sources/plugins/utils/nix-develop.nix @@ -0,0 +1,17 @@ +{ + empty = { + plugins.nix-develop.enable = true; + }; + + example = { + plugins.nix-develop = { + enable = true; + ignoredVariables = { + HOME = true; + }; + separatedVariables = { + "LUA_PATH" = ":"; + }; + }; + }; +}