2023-07-15 17:15:38 +00:00
|
|
|
{ lib, stdenv, fetchurl
|
|
|
|
, autoPatchelfHook, makeDesktopItem, copyDesktopItems, makeWrapper, gnugrep, nodePackages
|
|
|
|
, electron, python3, alsa-lib, gtk3, libdbusmenu, libxshmfence, mesa, nss
|
|
|
|
}:
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "whalebird";
|
2023-07-15 17:15:38 +00:00
|
|
|
version = "5.0.7";
|
2021-12-06 16:07:01 +00:00
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
src = let
|
2023-07-15 17:15:38 +00:00
|
|
|
downloads = "https://github.com/h3poteto/whalebird-desktop/releases/download/v${version}";
|
2022-06-26 10:26:21 +00:00
|
|
|
in
|
|
|
|
if stdenv.system == "x86_64-linux" then
|
|
|
|
fetchurl {
|
|
|
|
url = downloads + "/Whalebird-${version}-linux-x64.tar.bz2";
|
2023-07-15 17:15:38 +00:00
|
|
|
hash = "sha256-eufP038REwF2VwAxxI8R0S3fE8oJ+SX/CES5ozuut2w=";
|
2022-06-26 10:26:21 +00:00
|
|
|
}
|
|
|
|
else if stdenv.system == "aarch64-linux" then
|
|
|
|
fetchurl {
|
|
|
|
url = downloads + "/Whalebird-${version}-linux-arm64.tar.bz2";
|
2023-07-15 17:15:38 +00:00
|
|
|
hash = "sha256-U0xVTUUm6wsRxYc1w4vfNtVE6o8dNzXTSi+IX4mgDEE=";
|
2022-06-26 10:26:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
throw "Whalebird is not supported for ${stdenv.system}";
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
autoPatchelfHook
|
|
|
|
makeWrapper
|
2022-06-26 10:26:21 +00:00
|
|
|
copyDesktopItems
|
2023-07-15 17:15:38 +00:00
|
|
|
gnugrep
|
2021-12-06 16:07:01 +00:00
|
|
|
nodePackages.asar
|
|
|
|
];
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
buildInputs = [ alsa-lib gtk3 libdbusmenu libxshmfence mesa nss ];
|
2021-12-06 16:07:01 +00:00
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
desktopItems = [
|
|
|
|
(makeDesktopItem {
|
|
|
|
desktopName = "Whalebird";
|
|
|
|
comment = meta.description;
|
|
|
|
categories = [ "Network" ];
|
|
|
|
exec = "whalebird";
|
|
|
|
icon = "whalebird";
|
|
|
|
name = "whalebird";
|
|
|
|
})
|
|
|
|
];
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
unpackPhase = ''
|
2022-06-26 10:26:21 +00:00
|
|
|
mkdir -p opt
|
|
|
|
tar -xf ${src} -C opt
|
|
|
|
# remove the version/target suffix from the untar'd directory
|
|
|
|
mv opt/Whalebird-* opt/Whalebird
|
2021-12-06 16:07:01 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
# Necessary steps to find the tray icon
|
2023-07-15 17:15:38 +00:00
|
|
|
# For aarch64-linux, we need to overwrite this symlink first as it points to
|
|
|
|
# /usr/bin/python3
|
|
|
|
if [ "${stdenv.system}" = "aarch64-linux" ]
|
|
|
|
then ln -sf ${python3}/bin/python3 \
|
|
|
|
opt/Whalebird/resources/app.asar.unpacked/node_modules/better-sqlite3/build/node_gyp_bins/python3
|
|
|
|
fi
|
2021-12-06 16:07:01 +00:00
|
|
|
asar extract opt/Whalebird/resources/app.asar "$TMP/work"
|
2023-07-15 17:15:38 +00:00
|
|
|
substituteInPlace "$TMP/work/dist/electron/main.js" \
|
|
|
|
--replace "$(grep -oE '.{2},"tray_icon.png"' "$TMP/work/dist/electron/main.js")" \
|
|
|
|
"\"$out/opt/Whalebird/resources/build/icons/tray_icon.png\""
|
2021-12-06 16:07:01 +00:00
|
|
|
asar pack --unpack='{*.node,*.ftz,rect-overlay}' "$TMP/work" opt/Whalebird/resources/app.asar
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir $out
|
2022-06-26 10:26:21 +00:00
|
|
|
mv opt $out
|
|
|
|
|
|
|
|
# install icons
|
|
|
|
for icon in $out/opt/Whalebird/resources/build/icons/*.png; do
|
|
|
|
mkdir -p "$out/share/icons/hicolor/$(basename $icon .png)/apps"
|
|
|
|
ln -s "$icon" "$out/share/icons/hicolor/$(basename $icon .png)/apps/whalebird.png"
|
|
|
|
done
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
makeWrapper ${electron}/bin/electron $out/bin/whalebird \
|
2022-06-26 10:26:21 +00:00
|
|
|
--add-flags $out/opt/Whalebird/resources/app.asar \
|
2022-10-06 18:32:54 +00:00
|
|
|
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}"
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Electron based Mastodon, Pleroma and Misskey client for Windows, Mac and Linux";
|
|
|
|
homepage = "https://whalebird.social";
|
2022-06-26 10:26:21 +00:00
|
|
|
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
|
2023-07-15 17:15:38 +00:00
|
|
|
license = licenses.gpl3Only;
|
|
|
|
maintainers = with maintainers; [ wolfangaukang colinsane weathercold ];
|
2022-06-26 10:26:21 +00:00
|
|
|
platforms = [ "x86_64-linux" "aarch64-linux" ];
|
2021-12-06 16:07:01 +00:00
|
|
|
};
|
|
|
|
}
|