diff --git a/modules/programs/kakoune.nix b/modules/programs/kakoune.nix index 3c2349151..6db311a13 100644 --- a/modules/programs/kakoune.nix +++ b/modules/programs/kakoune.nix @@ -489,6 +489,10 @@ let }; }; + kakouneWithPlugins = pkgs.wrapKakoune pkgs.kakoune-unwrapped { + configure = { plugins = cfg.plugins; }; + }; + configFile = let wrapOptions = with cfg.config.wrapLines; concatStrings [ @@ -634,11 +638,22 @@ in { ~/.config/kak/kakrc. ''; }; + + plugins = mkOption { + type = with types; listOf package; + default = [ ]; + example = literalExample "[ pkgs.kakounePlugins.kak-fzf ]"; + description = '' + List of kakoune plugins to install. To get a list of + supported plugins run: + nix-env -f '<nixpkgs>' -qaP -A kakounePlugins. + ''; + }; }; }; config = mkIf cfg.enable { - home.packages = [ pkgs.kakoune ]; + home.packages = [ kakouneWithPlugins ]; xdg.configFile."kak/kakrc".source = configFile; }; } diff --git a/tests/modules/programs/kakoune/default.nix b/tests/modules/programs/kakoune/default.nix index 9f906a946..1e6e077df 100644 --- a/tests/modules/programs/kakoune/default.nix +++ b/tests/modules/programs/kakoune/default.nix @@ -1,4 +1,6 @@ { + kakoune-no-plugins = ./no-plugins.nix; + kakoune-use-plugins = ./use-plugins.nix; kakoune-whitespace-highlighter = ./whitespace-highlighter.nix; kakoune-whitespace-highlighter-corner-cases = ./whitespace-highlighter-corner-cases.nix; diff --git a/tests/modules/programs/kakoune/no-plugins.nix b/tests/modules/programs/kakoune/no-plugins.nix new file mode 100644 index 000000000..76dea5440 --- /dev/null +++ b/tests/modules/programs/kakoune/no-plugins.nix @@ -0,0 +1,13 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.kakoune = { enable = true; }; + + nmt.script = '' + assertFileNotRegex home-path/share/kak/plugins.kak . # file is empty + ''; + }; +} diff --git a/tests/modules/programs/kakoune/use-plugins.nix b/tests/modules/programs/kakoune/use-plugins.nix new file mode 100644 index 000000000..7b23627db --- /dev/null +++ b/tests/modules/programs/kakoune/use-plugins.nix @@ -0,0 +1,18 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.kakoune = { + enable = true; + plugins = [ pkgs.kakounePlugins.kak-powerline ]; + }; + + nmt.script = let plugins_kak = "home-path/share/kak/plugins.kak"; + in '' + assertFileRegex ${plugins_kak} \ + '^source "/nix/store/.*-kak-powerline/share/kak/autoload/plugins/powerline/.*.kak"$' + ''; + }; +}