From 9ca73dd13f3771c0e32713b519f4a0ea6d2bb6d2 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Mon, 4 Jan 2021 00:35:24 +0100 Subject: [PATCH] kakounePlugins: add buildKakounePlugin helper Same as buildVimPlugin but for Kakoune --- .../kakoune/plugins/build-kakoune-plugin.nix | 33 +++++++++++++++++++ .../editors/kakoune/plugins/kakoune-utils.nix | 4 +++ pkgs/top-level/all-packages.nix | 1 + 3 files changed, 38 insertions(+) create mode 100644 pkgs/applications/editors/kakoune/plugins/build-kakoune-plugin.nix create mode 100644 pkgs/applications/editors/kakoune/plugins/kakoune-utils.nix diff --git a/pkgs/applications/editors/kakoune/plugins/build-kakoune-plugin.nix b/pkgs/applications/editors/kakoune/plugins/build-kakoune-plugin.nix new file mode 100644 index 000000000000..f35a175312c0 --- /dev/null +++ b/pkgs/applications/editors/kakoune/plugins/build-kakoune-plugin.nix @@ -0,0 +1,33 @@ +{ lib, stdenv, rtpPath ? "share/kak/autoload/plugins" }: +rec { + buildKakounePlugin = attrs@{ + name ? "${attrs.pname}-${attrs.version}", + namePrefix ? "kakplugin-", + src, + unpackPhase ? "", + configurePhase ? "", + buildPhase ? "", + preInstall ? "", + postInstall ? "", + path ? lib.getName name, + ... + }: + stdenv.mkDerivation ((builtins.removeAttrs attrs [ "namePrefix" "path" ]) // { + name = namePrefix + name; + + installPhase = '' + runHook preInstall + + target=$out/${rtpPath}/${path} + mkdir -p $out/${rtpPath} + cp -r . $target + + runHook postInstall + ''; + }); + + buildKakounePluginFrom2Nix = attrs: buildKakounePlugin ({ + buildPhase = ":"; + configurePhase = ":"; + } // attrs); +} diff --git a/pkgs/applications/editors/kakoune/plugins/kakoune-utils.nix b/pkgs/applications/editors/kakoune/plugins/kakoune-utils.nix new file mode 100644 index 000000000000..11a1cc130d6c --- /dev/null +++ b/pkgs/applications/editors/kakoune/plugins/kakoune-utils.nix @@ -0,0 +1,4 @@ +{ lib, stdenv }: +{ + inherit (import ./build-kakoune-plugin.nix { inherit lib stdenv; }) buildKakounePlugin buildKakounePluginFrom2Nix; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6d9905206d1b..e1e650f456a0 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5533,6 +5533,7 @@ in kakoune = wrapKakoune kakoune-unwrapped { plugins = [ ]; # override with the list of desired plugins }; + kakouneUtils = callPackage ../applications/editors/kakoune/plugins/kakoune-utils.nix { }; kak-lsp = callPackage ../tools/misc/kak-lsp { inherit (darwin.apple_sdk.frameworks) Security;