discord: add openasar option
This commit is contained in:
parent
e0a42267f7
commit
4ecf88be2d
4 changed files with 65 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
|||
{ pname, version, src, meta, stdenv, binaryName, desktopName, undmg }:
|
||||
{ pname, version, src, openasar, meta, stdenv, binaryName, desktopName, lib, undmg }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
inherit pname version src meta;
|
||||
|
@ -8,7 +8,15 @@ stdenv.mkDerivation {
|
|||
sourceRoot = ".";
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/Applications
|
||||
cp -r "${desktopName}.app" $out/Applications
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
postInstall = lib.strings.optionalString (openasar != null) ''
|
||||
cp -f ${openasar} $out/Applications/${desktopName}.app/Contents/Resources/app.asar
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ branch ? "stable", pkgs, lib, stdenv }:
|
||||
{ branch ? "stable", pkgs, lib, stdenv, withOpenASAR ? false }:
|
||||
let
|
||||
inherit (pkgs) callPackage fetchurl;
|
||||
versions = if stdenv.isLinux then {
|
||||
|
@ -61,8 +61,11 @@ let
|
|||
++ lib.optionals (branch == "ptb") [ "aarch64-darwin" ];
|
||||
};
|
||||
package = if stdenv.isLinux then ./linux.nix else ./darwin.nix;
|
||||
|
||||
openasar = if withOpenASAR then callPackage ./openasar.nix { } else null;
|
||||
|
||||
packages = (builtins.mapAttrs
|
||||
(_: value: callPackage package (value // { inherit src version; meta = meta // { mainProgram = value.binaryName; }; }))
|
||||
(_: value: callPackage package (value // { inherit src version openasar; meta = meta // { mainProgram = value.binaryName; }; }))
|
||||
{
|
||||
stable = rec {
|
||||
pname = "discord";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ pname, version, src, meta, binaryName, desktopName, autoPatchelfHook
|
||||
{ pname, version, src, openasar, meta, binaryName, desktopName, autoPatchelfHook
|
||||
, makeDesktopItem, lib, stdenv, wrapGAppsHook, makeShellWrapper, alsa-lib, at-spi2-atk
|
||||
, at-spi2-core, atk, cairo, cups, dbus, expat, fontconfig, freetype, gdk-pixbuf
|
||||
, glib, gtk3, libcxx, libdrm, libnotify, libpulseaudio, libuuid, libX11
|
||||
|
@ -72,6 +72,8 @@ stdenv.mkDerivation rec {
|
|||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/{bin,opt/${binaryName},share/pixmaps,share/icons/hicolor/256x256/apps}
|
||||
mv * $out/opt/${binaryName}
|
||||
|
||||
|
@ -95,6 +97,12 @@ stdenv.mkDerivation rec {
|
|||
ln -s $out/opt/${binaryName}/discord.png $out/share/icons/hicolor/256x256/apps/${pname}.png
|
||||
|
||||
ln -s "${desktopItem}/share/applications" $out/share/
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
postInstall = lib.strings.optionalString (openasar != null) ''
|
||||
cp -f ${openasar} $out/opt/${binaryName}/resources/app.asar
|
||||
'';
|
||||
|
||||
desktopItem = makeDesktopItem {
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
{ lib, stdenv, fetchFromGitHub, nodejs, bash, nodePackages }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
version = "unstable-2022-06-10";
|
||||
pname = "openasar";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "GooseMod";
|
||||
repo = "OpenAsar";
|
||||
rev = "c6f2f5eb7827fea14cb4c54345af8ff6858c633a";
|
||||
sha256 = "m6e/WKGgkR8vjKcHSNdWE25MmDQM1Z3kgB24OJgbw/w=";
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue