threema-desktop: 1.2.31 -> 1.2.41, build from source
This commit is contained in:
parent
215d144f77
commit
681a32ff37
|
@ -1,55 +1,127 @@
|
||||||
{ lib, stdenv, fetchurl, dpkg, autoPatchelfHook, makeWrapper, electron
|
{ lib
|
||||||
, alsa-lib, glibc, gtk3, libxshmfence, mesa, nss }:
|
, buildNpmPackage
|
||||||
|
, fetchFromGitHub
|
||||||
|
, makeDesktopItem
|
||||||
|
, copyDesktopItems
|
||||||
|
, makeWrapper
|
||||||
|
, electron
|
||||||
|
, python3
|
||||||
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
let
|
||||||
pname = "threema-desktop";
|
version = "1.2.41";
|
||||||
version = "1.2.31";
|
electronSrc = fetchFromGitHub {
|
||||||
|
owner = "threema-ch";
|
||||||
src = fetchurl {
|
repo = "threema-web-electron";
|
||||||
# As Threema only offers a Latest Release url, the plan is to upload each
|
rev = "refs/tags/${version}";
|
||||||
# new release url to web.archive.org until their Github releases page gets populated.
|
hash = "sha256-gV64rNBwQxPpREi0NFzfCA7lSO65/h0CVRw2EcbFedM=";
|
||||||
url = "https://web.archive.org/web/20230731230034if_/https://releases.threema.ch/web-electron/v1/release/Threema-Latest.deb";
|
|
||||||
hash = "sha256-eZ/bjcSnrnzub1G4sbwPn3GCTwhDfFuYv9Plf5SJL90=";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
threema-web = buildNpmPackage rec {
|
||||||
|
pname = "threema-web";
|
||||||
|
version = "2.5.3";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "threema-ch";
|
||||||
|
repo = "threema-web";
|
||||||
|
rev = "refs/tags/v${version}";
|
||||||
|
hash = "sha256-RIYyDoEck+a0kPUzTpdNLdyd4+ZYGjjkAlkCp9/S7FY=";
|
||||||
|
};
|
||||||
|
|
||||||
|
npmDepsHash = "sha256-OqiPpjIdLwBfxEmbI+YFmYGt3beMqXyGZc9FCwbng4U=";
|
||||||
|
npmBuildScript = "dist";
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
python3 # Used by gyp
|
||||||
|
];
|
||||||
|
|
||||||
|
patches = [
|
||||||
|
"${electronSrc}/tools/patches/patch-user-agent.patch"
|
||||||
|
"${electronSrc}/tools/patches/patch-looks.patch"
|
||||||
|
];
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
# Content of ${electronSrc}/tools/patches/post-patch-threema-web.sh
|
||||||
|
export threema_web_version=threema-web-${version}
|
||||||
|
sed -i.bak -E "s/IN_MEMORY_SESSION_PASSWORD:(true|false|0|1|\!0|\!1)/IN_MEMORY_SESSION_PASSWORD:true/g" -- release/$threema_web_version/*.bundle.js
|
||||||
|
cp -r . "$out"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
consumer = buildNpmPackage rec {
|
||||||
|
pname = "threema-desktop-consumer";
|
||||||
|
inherit version;
|
||||||
|
src = electronSrc;
|
||||||
|
sourceRoot = "${src.name}/app";
|
||||||
|
npmDepsHash = "sha256-AaUxnvrVCgKWCtMzeXexVBxs/NuVwWH67x4eBGAcsxk=";
|
||||||
|
env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
|
||||||
|
dontNpmBuild = true;
|
||||||
|
prePatch = ''
|
||||||
|
rm -r dependencies/threema-web
|
||||||
|
cp -r ${threema-web} dependencies/threema-web
|
||||||
|
chmod +w dependencies/threema-web
|
||||||
|
'';
|
||||||
|
postInstall = ''
|
||||||
|
cp -r . "$out"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
buildNpmPackage rec {
|
||||||
|
pname = "threema-desktop";
|
||||||
|
inherit version;
|
||||||
|
src = electronSrc;
|
||||||
|
|
||||||
|
npmDepsHash = "sha256-f/Oy9cHBc9k54MDSeilPcTJe0txOS2sqNt2UCUf5+M8=";
|
||||||
|
|
||||||
|
env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
|
||||||
|
|
||||||
|
postPatch = ''
|
||||||
|
rm -r app
|
||||||
|
cp -r ${consumer} app
|
||||||
|
chmod +w app
|
||||||
|
'';
|
||||||
|
|
||||||
|
npmBuildScript = "app:build:electron:main";
|
||||||
|
|
||||||
|
# We need to install the consumer
|
||||||
|
dontNpmInstall = true;
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
dpkg
|
copyDesktopItems
|
||||||
autoPatchelfHook
|
|
||||||
makeWrapper
|
makeWrapper
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs = [ alsa-lib glibc gtk3 libxshmfence mesa nss ];
|
desktopItems = [
|
||||||
|
(makeDesktopItem {
|
||||||
|
name = "threema-desktop";
|
||||||
|
exec = meta.mainProgram;
|
||||||
|
icon = "threema";
|
||||||
|
desktopName = "Threema Desktop";
|
||||||
|
comment = meta.description;
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
dontBuild = true;
|
postInstall = ''
|
||||||
dontConfigure = true;
|
mkdir -p $out/opt
|
||||||
|
cp -r app $out/opt/threema
|
||||||
|
|
||||||
unpackPhase = ''
|
for dir in assets dependencies; do
|
||||||
# Can't unpack with the common dpkg-deb -x method
|
ln -s $out/opt/threema/$dir $out/opt/threema/dist/src/$dir
|
||||||
dpkg --fsys-tarfile $src | tar --extract
|
done
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
mkdir -p $out/share/pixmaps
|
||||||
runHook preInstall
|
cp $out/opt/threema/assets/icons/svg/consumer.svg $out/share/pixmaps/threema.svg
|
||||||
|
|
||||||
# This will cause confusion, not needed
|
|
||||||
rm -r usr/bin
|
|
||||||
mv usr $out
|
|
||||||
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
|
||||||
|
|
||||||
postFixup = ''
|
|
||||||
mv $out/share/applications/threema.desktop $out/share/applications/threema-desktop.desktop
|
|
||||||
makeWrapper ${electron}/bin/electron $out/bin/threema \
|
makeWrapper ${electron}/bin/electron $out/bin/threema \
|
||||||
--add-flags $out/lib/threema/resources/app.asar
|
--add-flags $out/opt/threema/dist/src/main.js
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "Desktop client for Threema, a privacy-focused end-to-end encrypted mobile messenger";
|
description = "Desktop client for Threema, a privacy-focused end-to-end encrypted mobile messenger";
|
||||||
mainProgram = "threema";
|
|
||||||
homepage = "https://threema.ch";
|
homepage = "https://threema.ch";
|
||||||
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
|
|
||||||
license = licenses.agpl3Only;
|
license = licenses.agpl3Only;
|
||||||
|
mainProgram = "threema";
|
||||||
maintainers = with maintainers; [ wolfangaukang ];
|
maintainers = with maintainers; [ wolfangaukang ];
|
||||||
platforms = [ "x86_64-linux" ];
|
platforms = [ "x86_64-linux" ];
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user