1{
2 lib,
3 symlinkJoin,
4 makeWrapper,
5 kakoune,
6 plugins ? [ ],
7 configure ? { },
8}:
9
10let
11 # "plugins" is the preferred way, but some configurations may be
12 # using "configure.plugins", so accept both
13 requestedPlugins = plugins ++ (configure.plugins or [ ]);
14
15in
16symlinkJoin {
17 name = "kakoune-${kakoune.version}";
18
19 nativeBuildInputs = [ makeWrapper ];
20
21 paths = [ kakoune ] ++ requestedPlugins;
22
23 postBuild = ''
24 # create a directory for bins that kakoune needs
25 # access to, without polluting the users path by adding
26 # that binary nested with this symlinkJoin.
27 mkdir -p $out/share/kak/bin
28
29 # location of kak binary is used to find ../share/kak/autoload,
30 # unless explicitly overriden with KAKOUNE_RUNTIME
31 rm "$out/bin/kak"
32 makeWrapper "${kakoune}/bin/kak" "$out/bin/kak" \
33 --set KAKOUNE_RUNTIME "$out/share/kak" \
34 --suffix PATH : "$out/share/kak/bin"
35
36 # currently kakoune ignores doc files if they are symlinks, so workaround by
37 # copying doc files over, so they become regular files...
38 mkdir "$out/DELETE_ME"
39 mv "$out/share/kak/doc" "$out/DELETE_ME"
40 cp -r --dereference "$out/DELETE_ME/doc" "$out/share/kak"
41 rm -Rf "$out/DELETE_ME"
42 '';
43
44 meta = kakoune.meta // {
45 priority = (kakoune.meta.priority or lib.meta.defaultPriority) - 1;
46 };
47}