anvil-editor: init at 0.4
[NixPkgs.git] / pkgs / applications / misc / whalebird / default.nix
blobe46a1af85c82b7204a377e037577b377c8fbc5f7
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , makeDesktopItem
5 , copyDesktopItems
6 , makeWrapper
7 , electron
8 , cacert
9 , gitMinimal
10 , yarn
12 stdenv.mkDerivation rec {
13   pname = "whalebird";
14   version = "6.1.0";
16   src = fetchFromGitHub {
17     owner = "h3poteto";
18     repo = "whalebird-desktop";
19     rev = "v${version}";
20     hash = "sha256-Jf+vhsfVjNrxdBkwwh3D3d2AlsGHfmEn90dq2QrKi2k=";
21   };
22   # we cannot use fetchYarnDeps because that doesn't support yarn 2/berry lockfiles
23   offlineCache = stdenv.mkDerivation {
24     name = "whalebird-${version}-offline-cache";
25     inherit src;
27     nativeBuildInputs = [
28       cacert # needed for git
29       gitMinimal # needed to download git dependencies
30       yarn
31     ];
33     buildPhase = ''
34       export HOME=$(mktemp -d)
35       yarn config set enableTelemetry 0
36       yarn config set cacheFolder $out
37       yarn config set --json supportedArchitectures.os '[ "linux" ]'
38       yarn config set --json supportedArchitectures.cpu '[ "arm64", "x64" ]'
39       yarn
40     '';
42     outputHashMode = "recursive";
43     outputHash = "sha256-SJCJq1vkO/jH9YgB3rV/pK4wV5Prm3sNjOj9YwL6XTw=";
44   };
46   nativeBuildInputs = [
47     makeWrapper
48     copyDesktopItems
49     yarn
50   ];
52   desktopItems = [
53     (makeDesktopItem {
54       desktopName = "Whalebird";
55       comment = meta.description;
56       categories = [ "Network" ];
57       exec = "whalebird";
58       icon = "whalebird";
59       name = "whalebird";
60     })
61   ];
63   ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
65   buildPhase = ''
66     runHook preBuild
68     export HOME=$(mktemp -d)
69     yarn config set enableTelemetry 0
70     yarn config set cacheFolder ${offlineCache}
72     yarn --immutable-cache
73     yarn run nextron build --no-pack
74     yarn run electron-builder --dir \
75       --config electron-builder.yml \
76       -c.electronDist="${electron.dist}" \
77       -c.electronVersion=${electron.version}
79     runHook postBuild
80   '';
82   installPhase = ''
83     runHook preInstall
85     mkdir -p $out/opt
86     cp -r ./dist/*-unpacked $out/opt/Whalebird
88     # Install icons
89     # Taken from https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=whalebird#n41
90     for i in 16 32 128 256 512; do
91       install -Dm644 "resources/icons/icon.iconset/icon_$i"x"$i.png" \
92         "$out/share/icons/hicolor/$i"x"$i/apps/whalebird.png"
93     done
94     install -Dm644 "resources/icons/icon.iconset/icon_32x32@2x.png" \
95       "$out/share/icons/hicolor/64x64/apps/whalebird.png"
97     makeWrapper "${electron}/bin/electron" "$out/bin/whalebird" \
98       --add-flags "$out/opt/Whalebird/resources/app.asar" \
99       --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}"
101     runHook postInstall
102   '';
104   meta = with lib; {
105     description = "Single-column Fediverse client for desktop";
106     mainProgram = "whalebird";
107     homepage = "https://whalebird.social";
108     changelog = "https://github.com/h3poteto/whalebird-desktop/releases/tag/v${version}";
109     license = licenses.gpl3Only;
110     maintainers = with maintainers; [ weathercold ];
111     platforms = [ "x86_64-linux" "aarch64-linux" ];
112   };