1{
2 lib,
3 stdenv,
4 appimageTools,
5 fetchurl,
6 _7zz,
7}:
8
9let
10 pname = "dbgate";
11 version = "6.6.0";
12 src =
13 fetchurl
14 {
15 aarch64-linux = {
16 url = "https://github.com/dbgate/dbgate/releases/download/v${version}/dbgate-${version}-linux_arm64.AppImage";
17 hash = "sha256-GFKsZ/rSMXWn2hAlRRdswDrooqUIGeIhEsMchIPEb5U=";
18 };
19 x86_64-linux = {
20 url = "https://github.com/dbgate/dbgate/releases/download/v${version}/dbgate-${version}-linux_x86_64.AppImage";
21 hash = "sha256-2g8XsljPvn2TITC1/PtBlgdrfwVDPnjmOXeOS/iQh5Q=";
22 };
23 x86_64-darwin = {
24 url = "https://github.com/dbgate/dbgate/releases/download/v${version}/dbgate-${version}-mac_x64.dmg";
25 hash = "sha256-ooLivNWt5IDKB779PLb4FOgk9jSU10IkB0D9OPLVKsE=";
26 };
27 aarch64-darwin = {
28 url = "https://github.com/dbgate/dbgate/releases/download/v${version}/dbgate-${version}-mac_universal.dmg";
29 hash = "sha256-PqgG8dGvr4S8BhxqfvYo2BiR5KoAWon9ZI8KGKT3ujI=";
30 };
31 }
32 .${stdenv.hostPlatform.system} or (throw "dbgate: ${stdenv.hostPlatform.system} is unsupported.");
33
34 passthru.updateScript = ./update.sh;
35
36 meta = {
37 description = "Database manager for MySQL, PostgreSQL, SQL Server, MongoDB, SQLite and others";
38 homepage = "https://dbgate.org/";
39 license = lib.licenses.mit;
40 maintainers = with lib.maintainers; [ luftmensch-luftmensch ];
41 changelog = "https://github.com/dbgate/dbgate/releases/tag/v${version}";
42 mainProgram = "dbgate";
43 platforms = [
44 "x86_64-linux"
45 "x86_64-darwin"
46 "aarch64-linux"
47 "aarch64-darwin"
48 ];
49 sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
50 };
51in
52if stdenv.hostPlatform.isDarwin then
53 stdenv.mkDerivation {
54 inherit
55 pname
56 version
57 src
58 passthru
59 meta
60 ;
61
62 sourceRoot = ".";
63
64 nativeBuildInputs = [ _7zz ];
65
66 unpackPhase = "7zz x ${src}";
67
68 installPhase = ''
69 runHook preInstall
70
71 mkdir -p $out/Applications
72 cp -r *.app $out/Applications
73
74 runHook postInstall
75 '';
76 }
77else
78 let
79 appimageContents = appimageTools.extract { inherit pname src version; };
80 in
81 appimageTools.wrapType2 {
82 inherit
83 pname
84 version
85 src
86 passthru
87 meta
88 ;
89
90 extraInstallCommands = ''
91 install -Dm644 ${appimageContents}/dbgate.desktop -t $out/share/applications
92 substituteInPlace $out/share/applications/dbgate.desktop \
93 --replace-warn "Exec=AppRun --no-sandbox" "Exec=dbgate"
94 cp -r ${appimageContents}/usr/share/icons $out/share
95 '';
96 }