Unverified Commit 33bff8b6 authored by Anish Pallati's avatar Anish Pallati
Browse files

cloudflare-warp: add darwin support, 2025.9.558 -> 2025.10.186.0

parent edb78a8b
Loading
Loading
Loading
Loading
+101 −50
Original line number Diff line number Diff line
@@ -20,19 +20,29 @@
  jq,
  ripgrep,
  common-updater-scripts,
  xar,
  cpio,
  headless ? false,
}:

let
  version = "2025.9.558";
  version = "2025.10.186.0";
  sources = {
    x86_64-linux = fetchurl {
      url = "https://pkg.cloudflareclient.com/pool/noble/main/c/cloudflare-warp/cloudflare-warp_${version}.0_amd64.deb";
      hash = "sha256-eYPy8YnP/vvYmvvjvF6Y0gSzdglsvoPW6CJ5npjrtpo=";
      url = "https://pkg.cloudflareclient.com/pool/noble/main/c/cloudflare-warp/cloudflare-warp_${version}_amd64.deb";
      hash = "sha256-l+csDSBXRAFb2075ciCAlE0bS5F48mAIK/Bv1r3Q8GE=";
    };
    aarch64-linux = fetchurl {
      url = "https://pkg.cloudflareclient.com/pool/noble/main/c/cloudflare-warp/cloudflare-warp_${version}.0_arm64.deb";
      hash = "sha256-K8XENo+9n3ChmQ33wAg/KiVHjNOKOXp6UQM2fpntgkE=";
      url = "https://pkg.cloudflareclient.com/pool/noble/main/c/cloudflare-warp/cloudflare-warp_${version}_arm64.deb";
      hash = "sha256-S6CfWYzcv+1Djj+TX+lrP5eG7oIpM0JrqtSw/UDD9ko=";
    };
    x86_64-darwin = fetchurl {
      url = "https://downloads.cloudflareclient.com/v1/download/macos/version/${version}";
      hash = "sha256-nnoOXPSpOJRyNdCC0/YAoBK8SwB+++qVwgZplrjNi2U=";
    };
    aarch64-darwin = fetchurl {
      url = "https://downloads.cloudflareclient.com/v1/download/macos/version/${version}";
      hash = "sha256-nnoOXPSpOJRyNdCC0/YAoBK8SwB+++qVwgZplrjNi2U=";
    };
  };
in
@@ -46,17 +56,24 @@ stdenv.mkDerivation (finalAttrs: {
      or (throw "Unsupported system: ${stdenv.hostPlatform.system}");

  nativeBuildInputs = [
    makeWrapper
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    xar
    cpio
  ]
  ++ lib.optionals stdenv.hostPlatform.isLinux [
    dpkg
    autoPatchelfHook
    versionCheckHook
    makeWrapper
  ]
  ++ lib.optionals (!headless) [
  ++ lib.optionals (!headless && stdenv.hostPlatform.isLinux) [
    copyDesktopItems
    desktop-file-utils
  ];

  buildInputs = [
  buildInputs = lib.optionals stdenv.hostPlatform.isLinux (
    [
      dbus
      libpcap
      openssl
@@ -65,7 +82,8 @@ stdenv.mkDerivation (finalAttrs: {
    ]
    ++ lib.optionals (!headless) [
      gtk3
  ];
    ]
  );

  desktopItems = lib.optionals (!headless) [
    (makeDesktopItem {
@@ -88,7 +106,32 @@ stdenv.mkDerivation (finalAttrs: {
    "libpcap.so.0.8"
  ];

  installPhase = ''
  unpackPhase = lib.optionalString stdenv.hostPlatform.isDarwin ''
    runHook preUnpack

    xar -xf $src
    zcat < Cloudflare_WARP_${version}.pkg/Payload | cpio -i

    runHook postUnpack
  '';

  installPhase =
    if stdenv.hostPlatform.isDarwin then
      ''
        runHook preInstall

        mkdir -p $out/Applications $out/bin

        cp -R "Cloudflare WARP.app" $out/Applications/

        for tool in warp-cli warp-dex warp-diag; do
          ln -s "$out/Applications/Cloudflare WARP.app/Contents/Resources/$tool" "$out/bin/$tool"
        done

        runHook postInstall
      ''
    else
      ''
        runHook preInstall

        mv usr $out
@@ -122,14 +165,19 @@ stdenv.mkDerivation (finalAttrs: {
        runHook postInstall
      '';

  postInstall = ''
  postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
    wrapProgram $out/bin/warp-svc --prefix PATH : ${lib.makeBinPath [ nftables ]}
    ${lib.optionalString (!headless) ''
      wrapProgram $out/bin/warp-cli --prefix PATH : ${lib.makeBinPath [ desktop-file-utils ]}
    ''}
  '';

  doInstallCheck = true;
  doInstallCheck = stdenv.hostPlatform.isLinux;

  # The Sparkle.framework in the upstream macOS package contains a broken symlink
  # (XPCServices -> Versions/Current/XPCServices) where the target doesn't exist.
  # This is present in the official installed app and doesn't affect functionality.
  dontCheckForBrokenSymlinks = stdenv.hostPlatform.isDarwin;

  passthru = {
    inherit sources;
@@ -151,7 +199,7 @@ stdenv.mkDerivation (finalAttrs: {
            -H 'X-GitHub-Api-Version: 2022-11-28' \
            'https://api.github.com/repos/cloudflare/cloudflare-docs/git/trees/production?recursive=true' |
            jq -r '[.tree[].path | select(startswith("src/content/warp-releases/linux/ga/"))] | max_by(split("/")[-1] | split(".") | map(tonumber?))' |
            rg '([^/]+)\.0\.yaml\b' --only-matching --replace '$1'
            rg '([^/]+)\.yaml\b' --only-matching --replace '$1'
        )"

        for platform in ${lib.escapeShellArgs finalAttrs.meta.platforms}; do
@@ -162,7 +210,7 @@ stdenv.mkDerivation (finalAttrs: {
  };

  meta = {
    changelog = "https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/warp-releases/linux/ga/${finalAttrs.version}.0.yaml";
    changelog = "https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/warp-releases/linux/ga/${finalAttrs.version}.yaml";
    description =
      "Replaces the connection between your device and the Internet with a modern, optimized, protocol"
      + lib.optionalString headless " (headless version)";
@@ -172,10 +220,13 @@ stdenv.mkDerivation (finalAttrs: {
    mainProgram = "warp-cli";
    maintainers = with lib.maintainers; [
      marcusramberg
      anish
    ];
    platforms = [
      "x86_64-linux"
      "aarch64-linux"
      "x86_64-darwin"
      "aarch64-darwin"
    ];
  };
})