diff --git a/modules/top-level/output.nix b/modules/top-level/output.nix index 66c47a28..7ec61453 100644 --- a/modules/top-level/output.nix +++ b/modules/top-level/output.nix @@ -46,8 +46,14 @@ in wrapRc = mkOption { type = types.bool; - description = "Should the config be included in the wrapper script."; - default = false; + description = '' + Whether the config will be included in the wrapper script. + + When enabled, the nixvim config will be passed to `nvim` using the `-u` option. + ''; + defaultText = lib.literalMD '' + Configured by your installation method: `false` when using the home-manager module, `true` otherwise. + ''; }; finalPackage = mkOption { @@ -284,20 +290,24 @@ in ''; }; - extraConfigLuaPre = lib.mkOrder 100 ( - # Add a global table at start of init - '' - -- Nixvim's internal module table - -- Can be used to share code throughout init.lua - local _M = {} - '' - + lib.optionalString config.wrapRc '' + # Set `wrapRc`s option default with even lower priority than `mkOptionDefault` + wrapRc = lib.mkOverride 1501 true; - -- Ignore the user lua configuration - vim.opt.runtimepath:remove(vim.fn.stdpath('config')) -- ~/.config/nvim - vim.opt.runtimepath:remove(vim.fn.stdpath('config') .. "/after") -- ~/.config/nvim/after - vim.opt.runtimepath:remove(vim.fn.stdpath('data') .. "/site") -- ~/.local/share/nvim/site - '' + extraConfigLuaPre = lib.mkOrder 100 ( + lib.concatStringsSep "\n" ( + lib.optional config.wrapRc '' + -- Ignore the user lua configuration + vim.opt.runtimepath:remove(vim.fn.stdpath('config')) -- ~/.config/nvim + vim.opt.runtimepath:remove(vim.fn.stdpath('config') .. "/after") -- ~/.config/nvim/after + vim.opt.runtimepath:remove(vim.fn.stdpath('data') .. "/site") -- ~/.local/share/nvim/site + '' + # Add a global table at start of init + ++ lib.singleton '' + -- Nixvim's internal module table + -- Can be used to share code throughout init.lua + local _M = {} + '' + ) ); extraPlugins = lib.mkIf config.wrapRc [ config.filesPlugin ]; diff --git a/wrappers/hm.nix b/wrappers/hm.nix index 3065a9ac..a07096f6 100644 --- a/wrappers/hm.nix +++ b/wrappers/hm.nix @@ -22,6 +22,13 @@ let }; modules = [ ./modules/hm.nix + # FIXME: this can't go in ./modules/hm.nix because we eval that module in the docs _without_ nixvim's modules + { + _file = ./hm.nix; + config = { + wrapRc = lib.mkOptionDefault false; + }; + } ]; check = false; }; diff --git a/wrappers/modules/darwin.nix b/wrappers/modules/darwin.nix index 4ca13061..454c45fd 100644 --- a/wrappers/modules/darwin.nix +++ b/wrappers/modules/darwin.nix @@ -1,8 +1,3 @@ -{ lib, ... }: { imports = [ ./enable.nix ]; - - config = { - wrapRc = lib.mkForce true; - }; } diff --git a/wrappers/modules/nixos.nix b/wrappers/modules/nixos.nix index b65e5d73..24037ad9 100644 --- a/wrappers/modules/nixos.nix +++ b/wrappers/modules/nixos.nix @@ -5,8 +5,4 @@ }; imports = [ ./enable.nix ]; - - config = { - wrapRc = lib.mkForce true; - }; } diff --git a/wrappers/modules/standalone.nix b/wrappers/modules/standalone.nix deleted file mode 100644 index c2f78fe5..00000000 --- a/wrappers/modules/standalone.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ lib, ... }: -{ - config = { - wrapRc = lib.mkForce true; - }; -} diff --git a/wrappers/standalone.nix b/wrappers/standalone.nix index 433a86b8..b764855d 100644 --- a/wrappers/standalone.nix +++ b/wrappers/standalone.nix @@ -18,7 +18,6 @@ let nixvimConfig = evalNixvim { modules = [ mod - ./modules/standalone.nix ]; extraSpecialArgs = { defaultPkgs = pkgs;