Unverified Commit b9c04f1e authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

fastmail-desktop: 1.0.0 -> 1.0.3, add linux support (#453579)

parents 7e030191 c77215da
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
{
  pname,
  version,
  src,
  passthru,
  meta,
  stdenvNoCC,
}:
stdenvNoCC.mkDerivation {
  inherit
    pname
    version
    src
    passthru
    meta
    ;

  installPhase = ''
    mkdir -p $out/Applications
    cp -R Fastmail.app $out/Applications/
  '';

  dontBuild = true;

  # Fastmail is notarized
  dontFixup = true;
}
+84 −0
Original line number Diff line number Diff line
{
  pname,
  version,
  src,
  passthru,
  meta,
  lib,
  stdenvNoCC,
  appimageTools,
  asar,
  autoPatchelfHook,
  makeWrapper,
  electron,
  libXScrnSaver,
  libXtst,
  libappindicator,
  libgcc,
  musl,
  vips,
}:
let
  appimageContents = appimageTools.extract { inherit pname version src; };
in
stdenvNoCC.mkDerivation (finalAttrs: {
  inherit pname version passthru;

  dontUnpack = true;
  dontBuild = true;

  strictDeps = true;

  nativeBuildInputs = [
    asar
    autoPatchelfHook
    makeWrapper
  ];

  buildInputs = [
    libgcc
    musl
    vips
  ];

  libPath = lib.makeLibraryPath [
    libXScrnSaver
    libXtst
    libappindicator
  ];

  installPhase = ''
    runHook preInstall

    mkdir -p "$out/opt"
    cp -r --no-preserve=mode "${appimageContents}/resources" "$out/opt/fastmail"
    asar extract "$out/opt/fastmail/app.asar" "$out/opt/fastmail/app.asar.unpacked"
    rm "$out/opt/fastmail/app.asar"

    install -D "${appimageContents}/production.desktop" "$out/share/applications/fastmail.desktop"
    substituteInPlace "$out/share/applications/fastmail.desktop" \
      --replace-fail "Exec=AppRun --no-sandbox %U" "Exec=fastmail" \
      --replace-fail "Icon=production" "Icon=fastmail" \

    for res in 16 24 32 48 64 128 256 512 1024; do
      resdir="''${res}x''${res}"
      mkdir -p "$out/share/icons/hicolor/$resdir/apps"
      cp -r --no-preserve=mode \
        "${appimageContents}/usr/share/icons/hicolor/$resdir/apps/production.png" \
        "$out/share/icons/hicolor/$resdir/apps/fastmail.png"
    done

    makeWrapper "${electron}/bin/electron" "$out/bin/fastmail" \
      --add-flags "$out/opt/fastmail/app.asar.unpacked" \
      --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-wayland-ime=true --wayland-text-input-version=3}}" \
      --prefix LD_LIBRARY_PATH : ${finalAttrs.libPath}:$out/opt/fastmail \
      --set-default ELECTRON_IS_DEV 0 \
      --inherit-argv0

    runHook postInstall
  '';

  meta = meta // {
    mainProgram = "fastmail";
  };
})
+20 −21
Original line number Diff line number Diff line
{
  lib,
  callPackage,
  stdenvNoCC,
  fetchurl,
  fetchzip,
}:
stdenvNoCC.mkDerivation (finalAttrs: {
  pname = "fastmail-desktop";
  version = "1.0.0";

  src = fetchzip {
    url = "https://dl.fastmailcdn.com/desktop/production/mac/arm64/Fastmail-${finalAttrs.version}-arm64-mac.zip";
    hash = "sha256-wIWU0F08wEQeLjbZz2LqahfyeOfowC+dDQkeMZI6gbk=";
    stripRoot = false;
  };
let
  inherit (stdenvNoCC.hostPlatform) isDarwin system;

  installPhase = ''
    mkdir -p $out/Applications
    cp -R Fastmail.app $out/Applications/
  '';

  dontBuild = true;
  sources = import ./sources.nix { inherit fetchurl fetchzip; };
in
callPackage (if isDarwin then ./darwin.nix else ./linux.nix) {
  pname = "fastmail-desktop";
  inherit (sources.${system} or (throw "Unsupported system: ${system}")) version src;

  # Fastmail is notarized
  dontFixup = true;
  passthru.updateScript = ./update.sh;

  meta = {
    description = "Dedicated desktop app for Fastmail";
    homepage = "https://www.fastmail.com/blog/desktop-app/";
    license = lib.licenses.unfree;
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
    maintainers = [ lib.maintainers.Enzime ];
    platforms = [ "aarch64-darwin" ];
    sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
    maintainers = [
      lib.maintainers.Enzime
      lib.maintainers.nekowinston
    ];
    platforms = [
      "aarch64-darwin"
      "x86_64-linux"
    ];
  };
})
}
+20 −0
Original line number Diff line number Diff line
# Generated by ./update.sh - do not update manually!
# Last updated: 2025-10-30
{ fetchurl, fetchzip }:
{
  aarch64-darwin = {
    version = "1.0.3";
    src = fetchzip {
      url = "https://dl.fastmailcdn.com/desktop/production/mac/arm64/Fastmail-1.0.3-arm64-mac.zip";
      hash = "sha512-lqJj0tTwOJx1jzzXtlKOOduUEtSgVHpQCM5WkbXjmOh2OejLRcdJ1Y9CxvZJGSPBGWrErKzytMOB8QmJ1BkIdw==";
      stripRoot = false;
    };
  };
  x86_64-linux = {
    version = "1.0.3";
    src = fetchurl {
      url = "https://dl.fastmailcdn.com/desktop/production/linux/x64/Fastmail-1.0.3.AppImage";
      hash = "sha512-L+h0GHAAlZndB4Q5Z7GiHuZqv1kTF5yCAJYYb9tPXnHfdcrwHvfBRnixEnVPPia46rp2IJ56z4ZS8RSut3ATFQ==";
    };
  };
}
+41 −0
Original line number Diff line number Diff line
#!/usr/bin/env nix-shell
#! nix-shell -i bash --pure -p cacert curl yq nix

set -euo pipefail

cd "$(readlink -e "$(dirname "${BASH_SOURCE[0]}")")"

x86_64_linux_info=$(curl -fsS "https://dl.fastmailcdn.com/desktop/production/linux/x64/latest-linux.yml")
aarch64_darwin_info=$(curl -fsS "https://dl.fastmailcdn.com/desktop/production/mac/arm64/latest-mac.yml")

x86_64_linux_version=$(yq -r '.version' <<<"$x86_64_linux_info")
aarch64_darwin_version=$(yq -r '.version' <<<"$aarch64_darwin_info")

x86_64_linux_url="https://dl.fastmailcdn.com/desktop/production/linux/x64/$(yq -r '.path' <<<"$x86_64_linux_info")"
aarch64_darwin_url="https://dl.fastmailcdn.com/desktop/production/mac/arm64/$(yq -r '.path' <<<"$aarch64_darwin_info")"

x86_64_linux_hash=$(nix-hash --type sha512 --to-sri "$(yq -r '.sha512' <<<"$x86_64_linux_info")")
aarch64_darwin_hash=$(nix-hash --type sha512 --to-sri "$(yq -r '.sha512' <<<"$aarch64_darwin_info")")

cat >sources.nix <<EOF
# Generated by ./update.sh - do not update manually!
# Last updated: $(date +%F)
{ fetchurl, fetchzip }:
{
  aarch64-darwin = {
    version = "$aarch64_darwin_version";
    src = fetchzip {
      url = "$aarch64_darwin_url";
      hash = "$aarch64_darwin_hash";
      stripRoot = false;
    };
  };
  x86_64-linux = {
    version = "$x86_64_linux_version";
    src = fetchurl {
      url = "$x86_64_linux_url";
      hash = "$x86_64_linux_hash";
    };
  };
}
EOF