about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/editors/kakoune/wrapper.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/applications/editors/kakoune/wrapper.nix')
-rw-r--r--nixpkgs/pkgs/applications/editors/kakoune/wrapper.nix44
1 files changed, 44 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/applications/editors/kakoune/wrapper.nix b/nixpkgs/pkgs/applications/editors/kakoune/wrapper.nix
new file mode 100644
index 000000000000..b4cc823880e7
--- /dev/null
+++ b/nixpkgs/pkgs/applications/editors/kakoune/wrapper.nix
@@ -0,0 +1,44 @@
+{ 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