Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

whalebird: 5.0.7 -> 6.0.4 #284125

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 66 additions & 54 deletions pkgs/applications/misc/whalebird/default.nix
Original file line number Diff line number Diff line change
@@ -1,38 +1,54 @@
{ lib, stdenv, fetchurl
, autoPatchelfHook, makeDesktopItem, copyDesktopItems, makeWrapper, gnugrep, asar
, electron, python3, alsa-lib, gtk3, libdbusmenu, libxshmfence, mesa, nss
{ lib
, stdenv
, fetchFromGitHub
, makeDesktopItem
, copyDesktopItems
, makeWrapper
, electron
, cacert
, gitMinimal
, yarn
}:

stdenv.mkDerivation rec {
pname = "whalebird";
version = "5.0.7";

src = let
downloads = "https://github.com/h3poteto/whalebird-desktop/releases/download/v${version}";
in
if stdenv.system == "x86_64-linux" then
fetchurl {
url = downloads + "/Whalebird-${version}-linux-x64.tar.bz2";
hash = "sha256-eufP038REwF2VwAxxI8R0S3fE8oJ+SX/CES5ozuut2w=";
}
else if stdenv.system == "aarch64-linux" then
fetchurl {
url = downloads + "/Whalebird-${version}-linux-arm64.tar.bz2";
hash = "sha256-U0xVTUUm6wsRxYc1w4vfNtVE6o8dNzXTSi+IX4mgDEE=";
}
else
throw "Whalebird is not supported for ${stdenv.system}";
version = "6.0.4";

src = fetchFromGitHub {
owner = "h3poteto";
repo = "whalebird-desktop";
rev = "v${version}";
hash = "sha256-Yx0GEEPJ+d4/RvCbqZdKR6iE2iUNbOJr+RuboqjT8z8=";
};
# we cannot use fetchYarnDeps because that doesn't support yarn 2/berry lockfiles
offlineCache = stdenv.mkDerivation {
name = "whalebird-${version}-offline-cache";
inherit src;

nativeBuildInputs = [
cacert # needed for git
gitMinimal # needed to download git dependencies
yarn
];

buildPhase = ''
export HOME=$(mktemp -d)
yarn config set enableTelemetry 0
yarn config set cacheFolder $out
yarn config set --json supportedArchitectures.os '[ "linux" ]'
yarn config set --json supportedArchitectures.cpu '[ "arm64", "x64" ]'
yarn
'';

outputHashMode = "recursive";
outputHash = "sha256-RjTGAgHRRQ4O3eTYpmTrl+KXafDZkWf1NH6lzdozVAA=";
};

nativeBuildInputs = [
autoPatchelfHook
makeWrapper
copyDesktopItems
gnugrep
asar
yarn
];

buildInputs = [ alsa-lib gtk3 libdbusmenu libxshmfence mesa nss ];

desktopItems = [
(makeDesktopItem {
desktopName = "Whalebird";
Expand All @@ -44,55 +60,51 @@ stdenv.mkDerivation rec {
})
];

unpackPhase = ''
mkdir -p opt
tar -xf ${src} -C opt
# remove the version/target suffix from the untar'd directory
mv opt/Whalebird-* opt/Whalebird
'';
ELECTRON_SKIP_BINARY_DOWNLOAD = "1";

buildPhase = ''
runHook preBuild

# Necessary steps to find the tray icon
# 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
asar extract opt/Whalebird/resources/app.asar "$TMP/work"
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\""
asar pack --unpack='{*.node,*.ftz,rect-overlay}' "$TMP/work" opt/Whalebird/resources/app.asar
export HOME=$(mktemp -d)
yarn config set enableTelemetry 0
yarn config set cacheFolder ${offlineCache}

yarn --immutable-cache
yarn run nextron build --no-pack
yarn run electron-builder --dir \
--config electron-builder.yml \
-c.electronDist="${electron}/libexec/electron" \
-c.electronVersion=${electron.version}

runHook postBuild
'';

installPhase = ''
runHook preInstall

mkdir $out
mv opt $out
mkdir -p $out/opt
cp -r ./dist/linux-unpacked $out/opt/Whalebird

# 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"
# Install icons
# Taken from https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=whalebird#n41
for i in 16 32 128 256 512; do
install -Dm644 "resources/icons/icon.iconset/icon_$i"x"$i.png" \
"$out/share/icons/hicolor/$i"x"$i/apps/whalebird.png"
done
install -Dm644 "resources/icons/icon.iconset/icon_32x32@2x.png" \
"$out/share/icons/hicolor/64x64/apps/whalebird.png"

makeWrapper ${electron}/bin/electron $out/bin/whalebird \
--add-flags $out/opt/Whalebird/resources/app.asar \
makeWrapper "${electron}/bin/electron" "$out/bin/whalebird" \
--add-flags "$out/opt/Whalebird/resources/app.asar" \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}"

runHook postInstall
'';

meta = with lib; {
description = "Electron based Mastodon, Pleroma and Misskey client for Windows, Mac and Linux";
description = "Single-column Fediverse client for desktop";
homepage = "https://whalebird.social";
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
sourceProvenance = with sourceTypes; [ fromSource ];
license = licenses.gpl3Only;
maintainers = with maintainers; [ wolfangaukang colinsane weathercold ];
platforms = [ "x86_64-linux" "aarch64-linux" ];
Expand Down
2 changes: 1 addition & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36035,7 +36035,7 @@ with pkgs;
wgnord = callPackage ../applications/networking/wgnord/default.nix { };

whalebird = callPackage ../applications/misc/whalebird {
electron = electron_21;
electron = electron_27;
};

windowlab = callPackage ../applications/window-managers/windowlab { };
Expand Down
Loading