1{
2 lib,
3 stdenv,
4 fetchurl,
5 unzip,
6 jre,
7 coreutils,
8 makeDesktopItem,
9 copyDesktopItems,
10}:
11
12stdenv.mkDerivation rec {
13 pname = "basex";
14 version = "12.0";
15
16 src = fetchurl {
17 url = "http://files.basex.org/releases/${version}/BaseX${
18 builtins.replaceStrings [ "." ] [ "" ] version
19 }.zip";
20 hash = "sha256-/9TeaAp2jckG77F8+J3aSpkoXWyTFXvXxnxXgpn58Zc=";
21 };
22
23 nativeBuildInputs = [
24 unzip
25 copyDesktopItems
26 ];
27 buildInputs = [ jre ];
28
29 desktopItems = lib.optional (!stdenv.hostPlatform.isDarwin) (makeDesktopItem {
30 name = "basex";
31 exec = "basexgui %f";
32 icon = "${./basex.svg}"; # icon copied from Ubuntu basex package
33 comment = "Visually query and analyse your XML data";
34 desktopName = "BaseX XML Database";
35 genericName = "XML database tool";
36 categories = [
37 "Development"
38 "Utility"
39 "Database"
40 ];
41 mimeTypes = [ "text/xml" ];
42 });
43
44 dontBuild = true;
45
46 installPhase = ''
47 runHook preInstall
48
49 # Remove Windows batch files (unclutter $out/bin)
50 rm ./bin/*.bat
51
52 mkdir -p "$out/share/basex"
53
54 cp -R bin etc lib webapp src BaseX.jar "$out"
55 cp -R readme.txt webapp "$out/share/basex"
56
57 # Use substitutions instead of wrapper scripts
58 for file in "$out"/bin/*; do
59 sed -i -e "s|/usr/bin/env bash|${stdenv.shell}|" \
60 -e "s|java|${jre}/bin/java|" \
61 -e "s|readlink|${coreutils}/bin/readlink|" \
62 -e "s|dirname|${coreutils}/bin/dirname|" \
63 -e "s|basename|${coreutils}/bin/basename|" \
64 -e "s|echo|${coreutils}/bin/echo|" \
65 "$file"
66 done
67
68 runHook postInstall
69 '';
70
71 meta = with lib; {
72 description = "XML database and XPath/XQuery processor";
73 longDescription = ''
74 BaseX is a very fast and light-weight, yet powerful XML database and
75 XPath/XQuery processor, including support for the latest W3C Full Text
76 and Update Recommendations. It supports large XML instances and offers a
77 highly interactive front-end (basexgui). Apart from two local standalone
78 modes, BaseX offers a client/server architecture.
79 '';
80 homepage = "https://basex.org/";
81 sourceProvenance = with sourceTypes; [ binaryBytecode ];
82 license = licenses.bsd3;
83 platforms = platforms.unix;
84 maintainers = [ maintainers.bjornfor ];
85 };
86}