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