Unverified Commit d6477988 authored by Weijia Wang's avatar Weijia Wang Committed by GitHub
Browse files

Merge pull request #238506 from Enzime/mullvad-aarch64

mullvad-vpn: support `aarch64-linux`
parents d61a701d 4da27723
Loading
Loading
Loading
Loading
+20 −5
Original line number Diff line number Diff line
@@ -64,15 +64,28 @@ let
    systemd
  ];

  version = "2023.4";

  selectSystem = attrs: attrs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");

  platform = selectSystem {
    x86_64-linux = "amd64";
    aarch64-linux = "arm64";
  };

  hash = selectSystem {
    x86_64-linux = "sha256-7NoifrX1/3pUJHTYK+2dVos/oFsKiYwyhCGi07SsEhM=";
    aarch64-linux = "sha256-e0lp+SpBUmtYBcJPvql8ALeCkVtneZ1Cd3IFMVX6R2Q=";
  };
in

stdenv.mkDerivation rec {
stdenv.mkDerivation {
  pname = "mullvad-vpn";
  version = "2023.4";
  inherit version;

  src = fetchurl {
    url = "https://github.com/mullvad/mullvadvpn-app/releases/download/${version}/MullvadVPN-${version}_amd64.deb";
    sha256 = "sha256-7NoifrX1/3pUJHTYK+2dVos/oFsKiYwyhCGi07SsEhM=";
    url = "https://github.com/mullvad/mullvadvpn-app/releases/download/${version}/MullvadVPN-${version}_${platform}.deb";
    inherit hash;
  };

  nativeBuildInputs = [
@@ -114,13 +127,15 @@ stdenv.mkDerivation rec {
    runHook postInstall
  '';

  passthru.updateScript = ./update.sh;

  meta = with lib; {
    homepage = "https://github.com/mullvad/mullvadvpn-app";
    description = "Client for Mullvad VPN";
    changelog = "https://github.com/mullvad/mullvadvpn-app/blob/${version}/CHANGELOG.md";
    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
    license = licenses.gpl3Only;
    platforms = [ "x86_64-linux" ];
    platforms = [ "x86_64-linux" "aarch64-linux" ];
    maintainers = with maintainers; [ Br1ght0ne ymarkus ataraxiasjel ];
  };

+36 −0
Original line number Diff line number Diff line
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnused gawk jq nix-prefetch

set -euo pipefail

ROOT="$(dirname "$(readlink -f "$0")")"
NIX_DRV="$ROOT/default.nix"
if [ ! -f "$NIX_DRV" ]; then
  echo "ERROR: cannot find default.nix in $ROOT"
  exit 1
fi

fetch_arch() {
  VER="$1"; ARCH="$2"
  URL="https://github.com/mullvad/mullvadvpn-app/releases/download/${VER}/MullvadVPN-${VER}_${ARCH}.deb"
  nix-prefetch "{ stdenv, fetchzip }:
stdenv.mkDerivation rec {
  pname = \"mullvad-vpn\"; version = \"${VER}\";
  src = fetchurl { url = \"$URL\"; };
}
"
}

replace_sha() {
  sed -i "s#$1 = \"sha256-.\{44\}\"#$1 = \"$2\"#" "$NIX_DRV"
}

MULLVAD_VER=$(curl -s https://api.mullvad.net/app/v1/releases/linux/2022.5 | jq -r '.latest_stable')

MULLVAD_LINUX_X64_SHA256=$(fetch_arch "$MULLVAD_VER" "amd64")
MULLVAD_LINUX_AARCH64_SHA256=$(fetch_arch "$MULLVAD_VER" "arm64")

sed -i "s/version = \".*\"/version = \"$MULLVAD_VER\"/" "$NIX_DRV"

replace_sha "x86_64-linux" "$MULLVAD_LINUX_X64_SHA256"
replace_sha "aarch64-linux" "$MULLVAD_LINUX_AARCH64_SHA256"
+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ stdenv.mkDerivation rec {
        bin = "source/macos/fasmg";
        asm = "source/macos/fasmg.asm";
      };
    }.${system} or (throw "Unsopported system: ${system}");
    }.${system} or (throw "Unsupported system: ${system}");

  in ''
    chmod +x ${path.bin}