nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 pname,
3 version,
4 src,
5 passthru,
6 meta,
7 lib,
8 stdenvNoCC,
9 appimageTools,
10 asar,
11 autoPatchelfHook,
12 makeWrapper,
13 electron,
14 libXScrnSaver,
15 libXtst,
16 libappindicator,
17 libgcc,
18 musl,
19 vips,
20}:
21let
22 appimageContents = appimageTools.extract { inherit pname version src; };
23in
24stdenvNoCC.mkDerivation (finalAttrs: {
25 inherit pname version passthru;
26
27 dontUnpack = true;
28 dontBuild = true;
29
30 strictDeps = true;
31
32 nativeBuildInputs = [
33 asar
34 autoPatchelfHook
35 makeWrapper
36 ];
37
38 buildInputs = [
39 libgcc
40 musl
41 vips
42 ];
43
44 libPath = lib.makeLibraryPath [
45 libXScrnSaver
46 libXtst
47 libappindicator
48 ];
49
50 installPhase = ''
51 runHook preInstall
52
53 mkdir -p "$out/opt"
54 cp -r --no-preserve=mode "${appimageContents}/resources" "$out/opt/fastmail"
55 asar extract "$out/opt/fastmail/app.asar" "$out/opt/fastmail/app.asar.unpacked"
56 rm "$out/opt/fastmail/app.asar"
57
58 install -D "${appimageContents}/production.desktop" "$out/share/applications/fastmail.desktop"
59 substituteInPlace "$out/share/applications/fastmail.desktop" \
60 --replace-fail "Exec=AppRun --no-sandbox %U" "Exec=fastmail" \
61 --replace-fail "Icon=production" "Icon=fastmail" \
62
63 for res in 16 24 32 48 64 128 256 512 1024; do
64 resdir="''${res}x''${res}"
65 mkdir -p "$out/share/icons/hicolor/$resdir/apps"
66 cp -r --no-preserve=mode \
67 "${appimageContents}/usr/share/icons/hicolor/$resdir/apps/production.png" \
68 "$out/share/icons/hicolor/$resdir/apps/fastmail.png"
69 done
70
71 makeWrapper "${electron}/bin/electron" "$out/bin/fastmail" \
72 --add-flags "$out/opt/fastmail/app.asar.unpacked" \
73 --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-wayland-ime=true --wayland-text-input-version=3}}" \
74 --prefix LD_LIBRARY_PATH : ${finalAttrs.libPath}:$out/opt/fastmail \
75 --set-default ELECTRON_IS_DEV 0 \
76 --inherit-argv0
77
78 runHook postInstall
79 '';
80
81 meta = meta // {
82 mainProgram = "fastmail";
83 };
84})