From 4d82c9269efc8078a238913f75cd70d682ea57d5 Mon Sep 17 00:00:00 2001 From: Thierry Delafontaine Date: Mon, 23 Feb 2026 10:52:18 +0100 Subject: [PATCH] proton-vpn: init darwin version at 6.4.0 - Separated platform-specific configurations into dedicated files: - `linux.nix` for Linux-specific package declaration - `darwin.nix` for macOS-specific package declaration - `package.nix` as the main orchestrator - Added `nix-update-script` to the Linux package - Use `writableTmpDirAsHomeHook` in Linux package --- pkgs/by-name/pr/proton-vpn/darwin.nix | 46 +++++++++++ pkgs/by-name/pr/proton-vpn/linux.nix | 96 +++++++++++++++++++++++ pkgs/by-name/pr/proton-vpn/package.nix | 103 ++++--------------------- 3 files changed, 155 insertions(+), 90 deletions(-) create mode 100644 pkgs/by-name/pr/proton-vpn/darwin.nix create mode 100644 pkgs/by-name/pr/proton-vpn/linux.nix diff --git a/pkgs/by-name/pr/proton-vpn/darwin.nix b/pkgs/by-name/pr/proton-vpn/darwin.nix new file mode 100644 index 000000000000..14df551ac737 --- /dev/null +++ b/pkgs/by-name/pr/proton-vpn/darwin.nix @@ -0,0 +1,46 @@ +{ + lib, + meta, + stdenvNoCC, + _7zz, + fetchurl, + nix-update-script, +}: +stdenvNoCC.mkDerivation (finalAttrs: { + pname = "proton-vpn"; + version = "6.4.0"; + + src = fetchurl { + url = "https://github.com/ProtonVPN/ios-mac-app/releases/download/mac%2F${finalAttrs.version}/ProtonVPN_mac_v${finalAttrs.version}.dmg"; + hash = "sha256-F5NS7NNqxNJcl7gFaqWtWxBxBbV6Btp7cyyDpegEGLQ="; + }; + + sourceRoot = "."; + + nativeBuildInputs = [ _7zz ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/Applications + cp -R ./ProtonVPN/ProtonVPN.app $out/Applications + + runHook postInstall + ''; + + passthru.updateScript = nix-update-script { + extraArgs = [ + "--version-regex" + "mac/(.*)" + ]; + }; + + meta = meta // { + changelog = "https://github.com/ProtonVPN/ios-mac-app/releases/tag/mac%2F${finalAttrs.version}"; + platforms = [ + "x86_64-darwin" + "aarch64-darwin" + ]; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + }; +}) diff --git a/pkgs/by-name/pr/proton-vpn/linux.nix b/pkgs/by-name/pr/proton-vpn/linux.nix new file mode 100644 index 000000000000..2ba403bb7900 --- /dev/null +++ b/pkgs/by-name/pr/proton-vpn/linux.nix @@ -0,0 +1,96 @@ +{ + lib, + meta, + python3Packages, + fetchFromGitHub, + gobject-introspection, + libappindicator-gtk3, + libayatana-appindicator, + libnotify, + wrapGAppsHook4, + writableTmpDirAsHomeHook, + nix-update-script, + withIndicator ? true, +}: +python3Packages.buildPythonApplication (finalAttrs: { + pname = "proton-vpn"; + version = "4.15.0"; + pyproject = true; + + src = fetchFromGitHub { + owner = "ProtonVPN"; + repo = "proton-vpn-gtk-app"; + tag = "v${finalAttrs.version}"; + hash = "sha256-bKUhrbfOLVjknljwW9UPo3Ros1Ayzb+be5KTUjPnIW0="; + }; + + nativeBuildInputs = [ + # Needed for the NM namespace + gobject-introspection + wrapGAppsHook4 + ]; + + buildInputs = [ + libnotify # gir typelib is used + ] + ++ lib.optionals withIndicator [ + # Adds AppIndicator3 namespace + libappindicator-gtk3 + # Adds AyatanaAppIndicator3 namespace + libayatana-appindicator + ]; + + build-system = with python3Packages; [ + setuptools + ]; + + dependencies = with python3Packages; [ + dbus-python + packaging + proton-core + proton-keyring-linux + proton-vpn-api-core + proton-vpn-local-agent + pycairo + pygobject3 + ]; + + dontWrapGApps = true; + + preFixup = '' + makeWrapperArgs+=("''${gappsWrapperArgs[@]}") + ''; + + postInstall = '' + mkdir -p $out/share/{applications,pixmaps} + + # Fix the desktop file to correctly identify the wrapped app and show the icon during runtime + substitute ${finalAttrs.src}/rpmbuild/SOURCES/proton.vpn.app.gtk.desktop $out/share/applications/proton.vpn.app.gtk.desktop \ + --replace-fail "StartupWMClass=protonvpn-app" "StartupWMClass=.protonvpn-app-wrapped" + install -Dm 644 ${finalAttrs.src}/rpmbuild/SOURCES/proton-vpn-logo.svg $out/share/pixmaps + ''; + + preCheck = '' + export XDG_RUNTIME_DIR=$(mktemp -d) + ''; + + nativeCheckInputs = [ + writableTmpDirAsHomeHook + ] + ++ (with python3Packages; [ + pytestCheckHook + pytest-cov-stub + ]); + + disabledTestPaths = [ + # Segmentation fault during widgets tests + "tests/unit/widgets" + ]; + + passthru.updateScript = nix-update-script { }; + + meta = meta // { + platforms = lib.platforms.linux; + mainProgram = "protonvpn-app"; + }; +}) diff --git a/pkgs/by-name/pr/proton-vpn/package.nix b/pkgs/by-name/pr/proton-vpn/package.nix index 88caca842619..f469bf82ddaf 100644 --- a/pkgs/by-name/pr/proton-vpn/package.nix +++ b/pkgs/by-name/pr/proton-vpn/package.nix @@ -1,99 +1,22 @@ { lib, - python3Packages, - fetchFromGitHub, - gobject-introspection, - libappindicator-gtk3, - libayatana-appindicator, - libnotify, - wrapGAppsHook4, - withIndicator ? true, + stdenv, + callPackage, }: - -python3Packages.buildPythonApplication (finalAttrs: { - pname = "proton-vpn"; - version = "4.15.0"; - pyproject = true; - - src = fetchFromGitHub { - owner = "ProtonVPN"; - repo = "proton-vpn-gtk-app"; - tag = "v${finalAttrs.version}"; - hash = "sha256-bKUhrbfOLVjknljwW9UPo3Ros1Ayzb+be5KTUjPnIW0="; - }; - - nativeBuildInputs = [ - # Needed for the NM namespace - gobject-introspection - wrapGAppsHook4 - ]; - - buildInputs = [ - libnotify # gir typelib is used - ] - ++ lib.optionals withIndicator [ - # Adds AppIndicator3 namespace - libappindicator-gtk3 - # Adds AyatanaAppIndicator3 namespace - libayatana-appindicator - ]; - - build-system = with python3Packages; [ - setuptools - ]; - - dependencies = with python3Packages; [ - dbus-python - packaging - proton-core - proton-keyring-linux - proton-vpn-api-core - proton-vpn-local-agent - pycairo - pygobject3 - ]; - - dontWrapGApps = true; - - preFixup = '' - makeWrapperArgs+=("''${gappsWrapperArgs[@]}") - ''; - - postInstall = '' - mkdir -p $out/share/{applications,pixmaps} - - # Fix the desktop file to correctly identify the wrapped app and show the icon during runtime - substitute ${finalAttrs.src}/rpmbuild/SOURCES/proton.vpn.app.gtk.desktop $out/share/applications/proton.vpn.app.gtk.desktop \ - --replace-fail "StartupWMClass=protonvpn-app" "StartupWMClass=.protonvpn-app-wrapped" - install -Dm 644 ${finalAttrs.src}/rpmbuild/SOURCES/proton-vpn-logo.svg $out/share/pixmaps - ''; - - preCheck = '' - # Needed for Permission denied: '/homeless-shelter' - export HOME=$(mktemp -d) - export XDG_RUNTIME_DIR=$(mktemp -d) - ''; - - nativeCheckInputs = with python3Packages; [ - pytestCheckHook - pytest-cov-stub - ]; - - disabledTestPaths = [ - # Segmentation fault during widgets tests - "tests/unit/widgets" - ]; - +let meta = { - description = "Proton VPN GTK app for Linux"; - homepage = "https://github.com/ProtonVPN/proton-vpn-gtk-app"; - license = lib.licenses.gpl3Plus; - platforms = lib.platforms.linux; - mainProgram = "protonvpn-app"; + description = "Official Proton VPN client"; + homepage = "https://protonvpn.com/"; + license = lib.licenses.gpl3Only; maintainers = with lib.maintainers; [ anthonyroussel - sebtm + delafthi rapiteanu + sebtm ]; }; -}) +in +if stdenv.hostPlatform.isDarwin then + callPackage ./darwin.nix { inherit meta; } +else + callPackage ./linux.nix { inherit meta; }