Unverified Commit f7942a23 authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

proton-pass: add update script (#493339)

parents 462de1f5 a685d0f8
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
{
  stdenv,
  undmg,
  pname,
  version,
  passthru,
  meta,
  undmg,
  fetchurl,
}:

stdenv.mkDerivation (finalAttrs: {
  inherit pname version meta;
  inherit
    pname
    version
    passthru
    meta
    ;

  src = fetchurl {
    url = "https://proton.me/download/PassDesktop/darwin/universal/ProtonPass_${version}.dmg";
    hash = "sha256-oo02IYOKZEsr0+4zimSFkutTGuS63ZvMZTeUTapZrVw=";
  };
  src = passthru.sources.${stdenv.hostPlatform.system};

  nativeBuildInputs = [ undmg ];

+8 −6
Original line number Diff line number Diff line
@@ -6,13 +6,18 @@
  asar,
  lib,
  version,
  fetchurl,
  pname,
  passthru,
  meta,
}:

stdenvNoCC.mkDerivation (finalAttrs: {
  inherit pname version meta;
  inherit
    pname
    version
    passthru
    meta
    ;

  nativeBuildInputs = [
    dpkg
@@ -20,10 +25,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {
    asar
  ];

  src = fetchurl {
    url = "https://proton.me/download/pass/linux/x64/proton-pass_${version}_amd64.deb";
    hash = "sha256-i5QQ1uzQ2tSDX4I/APL60QcHh9Ovc7ciueRnz7cZUuE=";
  };
  src = passthru.sources.${stdenvNoCC.hostPlatform.system};

  dontConfigure = true;
  dontBuild = true;
+44 −2
Original line number Diff line number Diff line
@@ -2,11 +2,48 @@
  lib,
  stdenv,
  callPackage,
  fetchurl,
  writeShellScript,
  curl,
  jq,
  common-updater-scripts,
}:
let
  pname = "proton-pass";
  version = "1.34.2";

  passthru = {
    sources = {
      "x86_64-linux" = fetchurl {
        url = "https://proton.me/download/pass/linux/x64/proton-pass_${version}_amd64.deb";
        hash = "sha256-i5QQ1uzQ2tSDX4I/APL60QcHh9Ovc7ciueRnz7cZUuE=";
      };
      "aarch64-darwin" = fetchurl {
        url = "https://proton.me/download/pass/macos/ProtonPass_${version}.dmg";
        hash = "sha256-oo02IYOKZEsr0+4zimSFkutTGuS63ZvMZTeUTapZrVw=";
      };
      "x86_64-darwin" = passthru.sources."aarch64-darwin";
    };
    updateScript = writeShellScript "update-proton-pass" ''
      set -o errexit
      export PATH="${
        lib.makeBinPath [
          curl
          jq
          common-updater-scripts
        ]
      }"
      NEW_VERSION=$(curl --silent https://proton.me/download/PassDesktop/linux/x64/version.json | jq -r '[.Releases[] | select(.CategoryName == "Stable")] | first | .Version')
      if [[ "${version}" = "$NEW_VERSION" ]]; then
          echo "The new version is the same as the old version."
          exit 0
      fi
      for platform in ${lib.escapeShellArgs meta.platforms}; do
        update-source-version "proton-pass" "$NEW_VERSION" --ignore-same-version --source-key="sources.$platform"
      done
    '';
  };

  meta = {
    description = "Desktop application for Proton Pass";
    homepage = "https://proton.me/pass";
@@ -17,11 +54,16 @@ let
      sebtm
      shunueda
    ];
    platforms = [ "x86_64-linux" ] ++ lib.platforms.darwin;
    platforms = builtins.attrNames passthru.sources;
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
    mainProgram = "proton-pass";
  };
in
callPackage (if stdenv.hostPlatform.isDarwin then ./darwin.nix else ./linux.nix) {
  inherit pname version meta;
  inherit
    pname
    version
    passthru
    meta
    ;
}