{ lib, stdenv, fetchFromGitHub, nodejs, bash, nodePackages, unzip }: stdenv.mkDerivation rec { pname = "openasar"; version = "unstable-2022-08-07"; src = fetchFromGitHub { owner = "GooseMod"; repo = "OpenAsar"; rev = "e0870784008a584229d3094e0988f5da155c7fd7"; hash = "sha256-t0b2SFlDDBSQEkOCQME0jsLJ8NvoXROTxoQgnoXM9eQ="; }; 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 ${nodePackages.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; [ pedrohlc ]; platforms = nodejs.meta.platforms; }; }