nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 dpkg,
6 unzip,
7 autoPatchelfHook,
8 makeWrapper,
9 runtimeShell,
10 glibc,
11 gcc,
12 glib,
13 gtk3,
14 pango,
15 cairo,
16 dbus,
17 at-spi2-atk,
18 cups,
19 libdrm,
20 gdk-pixbuf,
21 nss,
22 nspr,
23 libxrandr,
24 libxfixes,
25 libxext,
26 libxdamage,
27 libxcomposite,
28 libx11,
29 libxcb,
30 alsa-lib,
31 expat,
32 libxkbcommon,
33 libgbm,
34 vulkan-loader,
35 systemd,
36 libGL,
37 krb5,
38}:
39
40stdenv.mkDerivation (finalAttrs: {
41 pname = "beekeeper-studio";
42 version = "5.5.3";
43
44 src =
45 let
46 selectSystem = attrs: attrs.${stdenv.hostPlatform.system};
47 asset = selectSystem {
48 x86_64-linux = "beekeeper-studio_${finalAttrs.version}_amd64.deb";
49 aarch64-linux = "beekeeper-studio_${finalAttrs.version}_arm64.deb";
50 x86_64-darwin = "Beekeeper-Studio-${finalAttrs.version}-mac.zip";
51 aarch64-darwin = "Beekeeper-Studio-${finalAttrs.version}-arm64-mac.zip";
52 };
53 in
54 fetchurl {
55 url = "https://github.com/beekeeper-studio/beekeeper-studio/releases/download/v${finalAttrs.version}/${asset}";
56 hash = selectSystem {
57 x86_64-linux = "sha256-zbOePN975TWp7zo3XagKYPjHPQiz3r6ui2fPfNEboGs=";
58 aarch64-linux = "sha256-AoyaHBKO0gHgbq51D+OMH7SyUVnq2IjH4FIbeNepFHw=";
59 x86_64-darwin = "sha256-GzK9fmhW86IKER1IPsLNDwyz03rKuqCTO+hcPR/2QnM=";
60 aarch64-darwin = "sha256-pRBkgzp2w92/ACQaqpruwRtbfvg7f+nNE5rZ4YuQREc=";
61 };
62 };
63
64 nativeBuildInputs =
65 lib.optionals stdenv.hostPlatform.isLinux [
66 dpkg
67 autoPatchelfHook
68 makeWrapper
69 ]
70 ++ lib.optionals stdenv.hostPlatform.isDarwin [ unzip ];
71
72 buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
73 (lib.getLib stdenv.cc.cc)
74 libx11
75 libxcomposite
76 libxdamage
77 libxext
78 libxfixes
79 libxrandr
80 libxcb
81 libxkbcommon
82 glibc
83 gcc
84 libGL
85 glib
86 gtk3
87 pango
88 cairo
89 dbus
90 at-spi2-atk
91 cups
92 libdrm
93 gdk-pixbuf
94 nss
95 nspr
96 alsa-lib
97 expat
98 libgbm
99 vulkan-loader
100 krb5
101 ];
102
103 runtimeDependencies = lib.optionals stdenv.hostPlatform.isLinux (lib.getLib systemd);
104
105 installPhase = ''
106 runHook preInstall
107 ''
108 + lib.optionalString stdenv.hostPlatform.isLinux ''
109 cp -r usr $out
110 substituteInPlace $out/share/applications/beekeeper-studio.desktop \
111 --replace-fail '"/opt/Beekeeper Studio/beekeeper-studio"' "beekeeper-studio"
112 mkdir -p $out/opt $out/bin
113 cp -r opt/"Beekeeper Studio" $out/opt/beekeeper-studio
114 makeWrapper $out/opt/beekeeper-studio/beekeeper-studio-bin $out/bin/beekeeper-studio \
115 --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}"
116 ''
117 + lib.optionalString stdenv.hostPlatform.isDarwin ''
118 mkdir -p "$out/Applications" "$out/bin"
119 cp -R . "$out/Applications/Beekeeper Studio.app"
120 # Create a launcher script to run from the command line
121 cat > "$out/bin/beekeeper-studio" << EOF
122 #!${runtimeShell}
123 open -na "$out/Applications/Beekeeper Studio.app" --args "\$@"
124 EOF
125 chmod +x "$out/bin/beekeeper-studio"
126 ''
127 + ''
128 runHook postInstall
129 '';
130
131 dontFixup = stdenv.hostPlatform.isDarwin;
132
133 preFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
134 patchelf --add-needed libGL.so.1 \
135 --add-needed libEGL.so.1 \
136 --add-rpath ${
137 lib.makeLibraryPath [
138 libGL
139 ]
140 } $out/opt/beekeeper-studio/beekeeper-studio-bin
141 '';
142
143 passthru.updateScript = ./update.sh;
144
145 meta = {
146 description = "Modern and easy to use SQL client for MySQL, Postgres, SQLite, SQL Server, and more";
147 homepage = "https://www.beekeeperstudio.io";
148 changelog = "https://github.com/beekeeper-studio/beekeeper-studio/releases/tag/v${finalAttrs.version}";
149 license = lib.licenses.gpl3Only;
150 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
151 mainProgram = "beekeeper-studio";
152 maintainers = with lib.maintainers; [
153 milogert
154 alexnortung
155 iamanaws
156 ];
157 platforms = [
158 "aarch64-linux"
159 "x86_64-linux"
160 "aarch64-darwin"
161 "x86_64-darwin"
162 ];
163 knownVulnerabilities = [ "Electron version 32 is EOL" ];
164 };
165})