Merge pull request #329823 from ExpidusOS/fix/pkgsllvm/elfutils
[NixPkgs.git] / pkgs / by-name / op / openasar / package.nix
blob0d034ea1b8d1ca9787502bc275d12348dd571b8a
2   lib,
3   stdenv,
4   fetchFromGitHub,
5   unstableGitUpdater,
6   nodejs,
7   asar,
8   unzip,
9 }:
11 stdenv.mkDerivation (finalAttrs: {
12   pname = "openasar";
13   version = "0-unstable-2024-06-30";
15   src = fetchFromGitHub {
16     owner = "GooseMod";
17     repo = "OpenAsar";
18     rev = "5c875eb048e96543f1ec711fae522ace5e4a836c";
19     hash = "sha256-dlf4X+2W2GfL2E46ZM35PqpcoKHoZ4fhroOCLpye1D0=";
20   };
22   postPatch = ''
23     # Hardcode unzip path
24     substituteInPlace ./src/updater/moduleUpdater.js \
25       --replace \'unzip\' \'${unzip}/bin/unzip\'
26     # Remove auto-update feature
27     echo "module.exports = async () => log('AsarUpdate', 'Removed');" > ./src/asarUpdate.js
28   '';
30   buildPhase = ''
31     runHook preBuild
33     bash scripts/injectPolyfills.sh
34     substituteInPlace src/index.js --replace 'nightly' '${finalAttrs.version}'
35     ${nodejs}/bin/node scripts/strip.js
36     ${asar}/bin/asar pack src app.asar
38     runHook postBuild
39   '';
41   installPhase = ''
42     runHook preInstall
44     install app.asar $out
46     runHook postInstall
47   '';
49   doCheck = false;
51   passthru.updateScript = unstableGitUpdater {
52     # Only has a "nightly" tag (untaged version 0.2 is latest) see https://github.com/GooseMod/OpenAsar/commit/8f79dcef9b1f7732421235a392f06e5bd7382659
53     hardcodeZeroVersion = true;
54   };
56   meta = with lib; {
57     description = "Open-source alternative of Discord desktop's \"app.asar\"";
58     homepage = "https://openasar.dev";
59     license = licenses.agpl3Only;
60     maintainers = with maintainers; [
61       Scrumplex
62       jopejoe1
63     ];
64     platforms = nodejs.meta.platforms;
65   };