From 4da27723f3135a769ca52aff05148c76b7bb5123 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Mon, 19 Jun 2023 12:46:39 +1000 Subject: [PATCH] mullvad-vpn: support `aarch64-linux` --- .../networking/mullvad-vpn/default.nix | 29 +++++++++++---- .../networking/mullvad-vpn/update.sh | 36 +++++++++++++++++++ pkgs/development/compilers/fasmg/default.nix | 2 +- 3 files changed, 59 insertions(+), 8 deletions(-) create mode 100755 pkgs/applications/networking/mullvad-vpn/update.sh diff --git a/pkgs/applications/networking/mullvad-vpn/default.nix b/pkgs/applications/networking/mullvad-vpn/default.nix index 9f59d17682e0..cd4642f906d9 100644 --- a/pkgs/applications/networking/mullvad-vpn/default.nix +++ b/pkgs/applications/networking/mullvad-vpn/default.nix @@ -64,15 +64,28 @@ let systemd ]; -in - -stdenv.mkDerivation rec { - pname = "mullvad-vpn"; 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 { + pname = "mullvad-vpn"; + 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 ]; }; diff --git a/pkgs/applications/networking/mullvad-vpn/update.sh b/pkgs/applications/networking/mullvad-vpn/update.sh new file mode 100755 index 000000000000..97a6e2a44845 --- /dev/null +++ b/pkgs/applications/networking/mullvad-vpn/update.sh @@ -0,0 +1,36 @@ +#!/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" diff --git a/pkgs/development/compilers/fasmg/default.nix b/pkgs/development/compilers/fasmg/default.nix index 611a2bdb8f14..ec915bcb04bc 100644 --- a/pkgs/development/compilers/fasmg/default.nix +++ b/pkgs/development/compilers/fasmg/default.nix @@ -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}