From c0d70b3146358abea1a1bb75437cfbf73b4bae37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Wed, 6 Nov 2024 22:42:16 +0100 Subject: [PATCH 1/2] refactor(flake): reduce nvim duplication Also export smaller standalone nvim configurations --- flake-modules/nvim.nix | 73 +++++++++++++----------------------------- 1 file changed, 23 insertions(+), 50 deletions(-) diff --git a/flake-modules/nvim.nix b/flake-modules/nvim.nix index 6d9ee3e..97efc41 100644 --- a/flake-modules/nvim.nix +++ b/flake-modules/nvim.nix @@ -7,15 +7,8 @@ let nixvimLib = inputs.nixvim.lib.${system}; nixvim = inputs.nixvim.legacyPackages.${system}; - moduleDev = { - inherit pkgs; - extraSpecialArgs = { - inherit (inputs) unstable; - inherit system; - }; - module = import ../nvim/standalone.nix { standalone = true; }; - }; - moduleHeadless = { + testNvimModule = nixvimLib.check.mkTestDerivationFromNixvimModule; + nvimModule = extraConfig: { inherit pkgs; extraSpecialArgs = { inherit (inputs) unstable; @@ -23,57 +16,37 @@ }; module = { imports = [ (import ../nvim/standalone.nix { standalone = true; }) ]; - config.jhome.nvim.dev.enable = false; + config = extraConfig; }; }; - moduleNoLsp = { - inherit pkgs; - extraSpecialArgs = { - inherit (inputs) unstable; - inherit system; - }; - module = { - imports = [ (import ../nvim/standalone.nix { standalone = true; }) ]; - config.jhome.nvim.dev.bundleLSPs = false; - }; - }; - moduleNoTSGrammars = { - inherit pkgs; - extraSpecialArgs = { - inherit (inputs) unstable; - inherit system; - }; - module = { - imports = [ (import ../nvim/standalone.nix { standalone = true; }) ]; - config.jhome.nvim.dev.bundleGrammars = false; - }; - }; - moduleNoBundledBins = { - inherit pkgs; - extraSpecialArgs = { - inherit (inputs) unstable; - inherit system; - }; - module = { - imports = [ (import ../nvim/standalone.nix { standalone = true; }) ]; - config.jhome.nvim.dev = { - bundleLSPs = false; - bundleGrammars = false; - }; + moduleDev = nvimModule { }; + moduleHeadless = nvimModule { jhome.nvim.dev.enable = false; }; + moduleNoLsp = nvimModule { jhome.nvim.dev.bundleLSPs = false; }; + moduleNoTSGrammars = nvimModule { jhome.nvim.dev.bundleGrammars = false; }; + moduleNoBundledBins = nvimModule { + jhome.nvim.dev = { + bundleLSPs = false; + bundleGrammars = false; }; }; in { # Check standalone nvim build checks = { - nvimDev = nixvimLib.check.mkTestDerivationFromNixvimModule moduleDev; - nvimHeadless = nixvimLib.check.mkTestDerivationFromNixvimModule moduleHeadless; - nvimNoLsp = nixvimLib.check.mkTestDerivationFromNixvimModule moduleNoLsp; - nvimNoTSGrammars = nixvimLib.check.mkTestDerivationFromNixvimModule moduleNoTSGrammars; - nvimNoBundledBins = nixvimLib.check.mkTestDerivationFromNixvimModule moduleNoBundledBins; + nvimDev = testNvimModule moduleDev; + nvimHeadless = testNvimModule moduleHeadless; + nvimNoLsp = testNvimModule moduleNoLsp; + nvimNoTSGrammars = testNvimModule moduleNoTSGrammars; + nvimNoBundledBins = testNvimModule moduleNoBundledBins; }; # Nvim standalone module - packages.nvim = nixvim.makeNixvimWithModule moduleDev; + packages = { + nvim = nixvim.makeNixvimWithModule moduleDev; + # Smaller derivations + nvim-small = nixvim.makeNixvimWithModule moduleNoBundledBins; + nvim-no-ts = nixvim.makeNixvimWithModule moduleNoTSGrammars; + nvim-no-lsps = nixvim.makeNixvimWithModule moduleNoLsp; + }; }; } -- 2.47.0 From cab3dcbc3212e8e2715dc95d79d67f7dc1d21549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Wed, 6 Nov 2024 22:56:37 +0100 Subject: [PATCH 2/2] feat(nvim): remove TS tools when bundling grammars They are not needed as we are not building any grammars (we are bundling them) --- nvim/dev-plugins.nix | 8 ++++++++ nvim/options.nix | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/nvim/dev-plugins.nix b/nvim/dev-plugins.nix index 31c4096..07683d8 100644 --- a/nvim/dev-plugins.nix +++ b/nvim/dev-plugins.nix @@ -63,6 +63,14 @@ in } # Do not bundle treesitter grammars (lib.mkIf (!cfg.dev.bundleGrammars) { plugins.treesitter.grammarPackages = [ ]; }) + # Remove tools for building gramars when bundling them + (lib.mkIf cfg.dev.bundleGrammars { + plugins.treesitter = { + gccPackage = null; + nodejsPackage = null; + treesitterPackage = null; + }; + }) # Configure Formatters { extraPackages = [ diff --git a/nvim/options.nix b/nvim/options.nix index 40166fc..1e54e30 100644 --- a/nvim/options.nix +++ b/nvim/options.nix @@ -16,8 +16,8 @@ in type = types.submodule { options = { enable = mkDisableOption "development configuration"; - bundleLSPs = mkDisableOption "bundling LSPs with Neovim"; - bundleGrammars = mkDisableOption "bundling treesitter grammars with Neovim"; + bundleLSPs = mkDisableOption "bundling LSPs with Neovim (decreases size when disabled)"; + bundleGrammars = mkDisableOption "bundling treesitter grammars with Neovim (barely decreases size when disabled)"; }; }; default = { }; -- 2.47.0