summary refs log tree commit diff
path: root/pkgs/applications/editors/kakoune/plugins/build-kakoune-plugin.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/editors/kakoune/plugins/build-kakoune-plugin.nix')
-rw-r--r--pkgs/applications/editors/kakoune/plugins/build-kakoune-plugin.nix33
1 files changed, 33 insertions, 0 deletions
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 00000000000..f35a175312c
--- /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);
+}