nixpkgs/pkgs/applications/editors/kakoune/wrapper.nix
Jason Felice 2a911454d3 kakoune: support for adding plugins
Motivation: There is a thriving plugin ecosystem for Kakoune now,
and it is nice to add these in our Nix configurations. This was modeled
on neovim's plugins.

parinfer-rust is useable both standalone and as a Kakoune plugin,
so the plugin file inherits the same definition as pkgs.

I'll make PRs for other plugins if this gets accepted.
[Here](https://github.com/eraserhd/nixpkgs/tree/kak-ansi)'s a tested
branch for the `kak-ansi` plugin.
2019-06-25 17:17:08 -04:00

45 lines
1.1 KiB
Nix

{ stdenv, bash }:
with stdenv.lib;
kakoune:
let
getPlugins = { plugins ? [] }: plugins;
wrapper = { configure ? {} }:
stdenv.mkDerivation rec {
pname = "kakoune";
version = getVersion kakoune;
src = ./.;
buildCommand = ''
mkdir -p $out/share/kak
for plugin in ${strings.escapeShellArgs (getPlugins configure)}; do
if [[ -d $plugin/share/kak/autoload ]]; then
find "$plugin/share/kak/autoload" -type f -name '*.kak'| while read rcfile; do
printf 'source "%s"\n' "$rcfile"
done
fi
done >>$out/share/kak/plugins.kak
mkdir -p $out/bin
substitute ${src}/wrapper.sh $out/bin/kak \
--subst-var-by bash "${bash}" \
--subst-var-by kakoune "${kakoune}" \
--subst-var-by out "$out"
chmod +x $out/bin/kak
'';
preferLocalBuild = true;
buildInputs = [ bash kakoune ];
passthru = { unwrapped = kakoune; };
meta = kakoune.meta // {
# prefer wrapper over the package
priority = (kakoune.meta.priority or 0) - 1;
hydraPlatforms = [];
};
};
in
makeOverridable wrapper