nixpkgs/pkgs/applications/networking/instant-messengers/discord/openasar.nix
2023-11-28 11:32:26 -03:00

51 lines
1.2 KiB
Nix

{ lib, stdenv, fetchFromGitHub, nodejs, bash, asar, unzip }:
stdenv.mkDerivation rec {
pname = "openasar";
version = "unstable-2023-10-24";
src = fetchFromGitHub {
owner = "GooseMod";
repo = "OpenAsar";
rev = "eee9bab822e3dbd97a735d0050ddd41ba27917f2";
hash = "sha256-SSWQSqGgTZjowgrzF6qHZDTw/Y9xFHNTZvetxqZubYI=";
};
postPatch = ''
# Hardcode unzip path
substituteInPlace ./src/updater/moduleUpdater.js \
--replace \'unzip\' \'${unzip}/bin/unzip\'
# Remove auto-update feature
echo "module.exports = async () => log('AsarUpdate', 'Removed');" > ./src/asarUpdate.js
'';
buildPhase = ''
runHook preBuild
bash scripts/injectPolyfills.sh
substituteInPlace src/index.js --replace 'nightly' '${version}'
${nodejs}/bin/node scripts/strip.js
${asar}/bin/asar pack src app.asar
runHook postBuild
'';
installPhase = ''
runHook preInstall
install app.asar $out
runHook postInstall
'';
doCheck = false;
meta = with lib; {
description = "Open-source alternative of Discord desktop's \"app.asar\".";
homepage = "https://openasar.dev";
license = licenses.mit;
maintainers = with maintainers; [ ];
platforms = nodejs.meta.platforms;
};
}