about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Hoang <enzime@users.noreply.github.com>2023-06-19 12:46:39 +1000
committerMichael Hoang <enzime@users.noreply.github.com>2023-07-04 20:11:41 +1000
commit4da27723f3135a769ca52aff05148c76b7bb5123 (patch)
tree23b04f8d53512b3e01f97c3a03edc3bb3f119995
parent453da3c28f7a95374b73d1f3fd665dd40e6049e9 (diff)
mullvad-vpn: support `aarch64-linux`
-rw-r--r--pkgs/applications/networking/mullvad-vpn/default.nix25
-rwxr-xr-xpkgs/applications/networking/mullvad-vpn/update.sh36
-rw-r--r--pkgs/development/compilers/fasmg/default.nix2
3 files changed, 57 insertions, 6 deletions
diff --git a/pkgs/applications/networking/mullvad-vpn/default.nix b/pkgs/applications/networking/mullvad-vpn/default.nix
index 9f59d17682e07..cd4642f906d99 100644
--- a/pkgs/applications/networking/mullvad-vpn/default.nix
+++ b/pkgs/applications/networking/mullvad-vpn/default.nix
@@ -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 ];
   };
 
diff --git a/pkgs/applications/networking/mullvad-vpn/update.sh b/pkgs/applications/networking/mullvad-vpn/update.sh
new file mode 100755
index 0000000000000..97a6e2a448459
--- /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 611a2bdb8f14e..ec915bcb04bcf 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}