1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
{
lib,
stdenvNoCC,
fetchurl,
undmg,
makeWrapper,
openjdk21,
gnused,
autoPatchelfHook,
autoSignDarwinBinariesHook,
wrapGAppsHook3,
gtk3,
glib,
webkitgtk_4_1,
glib-networking,
override_xmx ? "1024m",
}:
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "dbeaver-bin";
version = "25.1.4";
src =
let
inherit (stdenvNoCC.hostPlatform) system;
selectSystem = attrs: attrs.${system} or (throw "Unsupported system: ${system}");
suffix = selectSystem {
x86_64-linux = "linux.gtk.x86_64-nojdk.tar.gz";
aarch64-linux = "linux.gtk.aarch64-nojdk.tar.gz";
x86_64-darwin = "macos-x86_64.dmg";
aarch64-darwin = "macos-aarch64.dmg";
};
hash = selectSystem {
x86_64-linux = "sha256-ZJUmuJqTD3cRMMdIIqbJRp6C2GacnRn1fxzL23Vg8og=";
aarch64-linux = "sha256-nHIk3MObHge5ACyype8HgFwvolPqrQ0BTDs/pYlsiW8=";
x86_64-darwin = "sha256-/dl3B2FLz7V27c5/q8L1HtssbT/lLAet0lhDvgGVqZM=";
aarch64-darwin = "sha256-/NClQkx6In9lS4vtk2lBhFHw0BLObmNqTIVJfhJcob4=";
};
in
fetchurl {
url = "https://github.com/dbeaver/dbeaver/releases/download/${finalAttrs.version}/dbeaver-ce-${finalAttrs.version}-${suffix}";
inherit hash;
};
sourceRoot = lib.optional stdenvNoCC.hostPlatform.isDarwin "DBeaver.app";
nativeBuildInputs = [
makeWrapper
]
++ lib.optionals (!stdenvNoCC.hostPlatform.isDarwin) [
gnused
wrapGAppsHook3
autoPatchelfHook
]
++ lib.optionals stdenvNoCC.hostPlatform.isDarwin [
undmg
autoSignDarwinBinariesHook
];
dontConfigure = true;
dontBuild = true;
prePatch = ''
substituteInPlace ${lib.optionalString stdenvNoCC.hostPlatform.isDarwin "Contents/Eclipse/"}dbeaver.ini \
--replace-fail '-Xmx1024m' '-Xmx${override_xmx}'
''
# remove the bundled JRE configuration on Darwin
# dont use substituteInPlace here because it would match "-vmargs"
+ lib.optionalString stdenvNoCC.hostPlatform.isDarwin ''
sed -i -e '/^-vm$/ { N; d; }' Contents/Eclipse/dbeaver.ini
'';
preInstall = ''
# most directories are for different architectures, only keep what we need
shopt -s extglob
pushd ${lib.optionalString stdenvNoCC.hostPlatform.isDarwin "Contents/Eclipse/"}plugins/com.sun.jna_*/com/sun/jna/
rm -r !(ptr|internal|linux-x86-64|linux-aarch64|darwin-x86-64|darwin-aarch64)/
popd
''
# remove the bundled JRE on Darwin
+ lib.optionalString stdenvNoCC.hostPlatform.isDarwin ''
rm -r Contents/Eclipse/jre/
'';
installPhase =
if !stdenvNoCC.hostPlatform.isDarwin then
''
runHook preInstall
mkdir -p $out/opt/dbeaver $out/bin
cp -r * $out/opt/dbeaver
makeWrapper $out/opt/dbeaver/dbeaver $out/bin/dbeaver \
--prefix PATH : "${openjdk21}/bin" \
--set JAVA_HOME "${openjdk21.home}" \
--prefix GIO_EXTRA_MODULES : "${glib-networking}/lib/gio/modules" \
--prefix LD_LIBRARY_PATH : "$out/lib:${
lib.makeLibraryPath [
gtk3
glib
webkitgtk_4_1
glib-networking
]
}"
mkdir -p $out/share/icons/hicolor/256x256/apps
ln -s $out/opt/dbeaver/dbeaver.png $out/share/icons/hicolor/256x256/apps/dbeaver.png
mkdir -p $out/share/applications
ln -s $out/opt/dbeaver/dbeaver-ce.desktop $out/share/applications/dbeaver.desktop
substituteInPlace $out/opt/dbeaver/dbeaver-ce.desktop \
--replace-fail "/usr/share/dbeaver-ce/dbeaver.png" "dbeaver" \
--replace-fail "/usr/share/dbeaver-ce/dbeaver" "$out/bin/dbeaver"
sed -i '/^Path=/d' $out/share/applications/dbeaver.desktop
runHook postInstall
''
else
''
runHook preInstall
mkdir -p $out/{Applications/dbeaver.app,bin}
cp -R . $out/Applications/dbeaver.app
wrapProgram $out/Applications/dbeaver.app/Contents/MacOS/dbeaver \
--prefix PATH : "${openjdk21}/bin" \
--set JAVA_HOME "${openjdk21.home}"
makeWrapper $out/{Applications/dbeaver.app/Contents/MacOS/dbeaver,bin/dbeaver}
runHook postInstall
'';
passthru.updateScript = ./update.sh;
meta = {
homepage = "https://dbeaver.io/";
changelog = "https://github.com/dbeaver/dbeaver/releases/tag/${finalAttrs.version}";
description = "Universal SQL Client for developers, DBA and analysts. Supports MySQL, PostgreSQL, MariaDB, SQLite, and more";
longDescription = ''
Free multi-platform database tool for developers, SQL programmers, database
administrators and analysts. Supports all popular databases: MySQL,
PostgreSQL, MariaDB, SQLite, Oracle, DB2, SQL Server, Sybase, MS Access,
Teradata, Firebird, Derby, etc.
'';
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
license = lib.licenses.asl20;
platforms = with lib.platforms; linux ++ darwin;
maintainers = with lib.maintainers; [
gepbird
mkg20001
yzx9
];
mainProgram = "dbeaver";
};
})
|