Unverified Commit 815d0b04 authored by jopejoe1's avatar jopejoe1 Committed by GitHub
Browse files

moonlight: init at 1.3.9; discord: added option to inject moonlight client...

moonlight: init at 1.3.9; discord: added option to inject moonlight client mod; maintainers: add ilys (#378711)
parents a8707f62 c13d37ad
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -9920,6 +9920,11 @@
    github = "ilyakooo0";
    githubId = 6209627;
  };
  ilys = {
    name = "ilys";
    github = "ilyist";
    githubId = 185637611;
  };
  imadnyc = {
    email = "me@imad.nyc";
    github = "imadnyc";
+13 −0
Original line number Diff line number Diff line
@@ -17,8 +17,14 @@
  openasar,
  withVencord ? false,
  vencord,
  withMoonlight ? false,
  moonlight,
}:

assert lib.assertMsg (
  !(withMoonlight && withVencord)
) "discord: Moonlight and Vencord can not be enabled at the same time";

let
  disableBreakingUpdates =
    runCommand "disable-breaking-updates.py"
@@ -72,6 +78,13 @@ stdenv.mkDerivation {
      mkdir $out/Applications/${desktopName}.app/Contents/Resources/app.asar
      echo '{"name":"discord","main":"index.js"}' > $out/Applications/${desktopName}.app/Contents/Resources/app.asar/package.json
      echo 'require("${vencord}/patcher.js")' > $out/Applications/${desktopName}.app/Contents/Resources/app.asar/index.js
    ''

    + lib.strings.optionalString withMoonlight ''
      mv $out/Applications/${desktopName}.app/Contents/Resources/app.asar $out/Applications/${desktopName}.app/Contents/Resources/_app.asar
      mkdir $out/Applications/${desktopName}.app/Contents/Resources/app.asar
      echo '{"name":"discord","main":"injector.js","private": true}' > $out/Applications/${desktopName}.app/Contents/Resources/app.asar/package.json
      echo 'require("${moonlight}/injector.js").inject(require("path").join(__dirname, "../_app.asar"));' > $out/Applications/${desktopName}.app/Contents/Resources/app.asar/injector.js
    '';

  passthru = {
+12 −0
Original line number Diff line number Diff line
@@ -62,9 +62,15 @@
  openasar,
  withVencord ? false,
  vencord,
  withMoonlight ? false,
  moonlight,
  withTTS ? true,
}:

assert lib.assertMsg (
  !(withMoonlight && withVencord)
) "discord: Moonlight and Vencord can not be enabled at the same time";

let
  disableBreakingUpdates =
    runCommand "disable-breaking-updates.py"
@@ -195,6 +201,12 @@ stdenv.mkDerivation rec {
      mkdir $out/opt/${binaryName}/resources/app.asar
      echo '{"name":"discord","main":"index.js"}' > $out/opt/${binaryName}/resources/app.asar/package.json
      echo 'require("${vencord}/patcher.js")' > $out/opt/${binaryName}/resources/app.asar/index.js
    ''
    + lib.strings.optionalString withMoonlight ''
      mv $out/opt/${binaryName}/resources/app.asar $out/opt/${binaryName}/resources/_app.asar
      mkdir $out/opt/${binaryName}/resources/app
      echo '{"name":"discord","main":"injector.js","private": true}' > $out/opt/${binaryName}/resources/app/package.json
      echo 'require("${moonlight}/injector.js").inject(require("path").join(__dirname, "../_app.asar"));' > $out/opt/${binaryName}/resources/app/injector.js
    '';

  desktopItem = makeDesktopItem {
+66 −0
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  nodejs,
  pnpm_9,
  fetchFromGitHub,
  nix-update-script,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "moonlight";
  version = "1.3.9";

  src = fetchFromGitHub {
    owner = "moonlight-mod";
    repo = "moonlight";
    tag = "v${finalAttrs.version}";
    hash = "sha256-WhPQ7JYfE8RBhDknBunKdW1VBxrklb3UGnMgk5LFVFA=";
  };

  nativeBuildInputs = [
    nodejs
    pnpm_9.configHook
  ];

  pnpmDeps = pnpm_9.fetchDeps {
    inherit (finalAttrs) pname version src;

    hash = "sha256-KZFHcW/OVjTDXZltxPYGuO+NWjuD5o6HE/E9JQZmrG8=";
  };

  buildPhase = ''
    runHook preBuild

    pnpm run build

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    cp -r dist $out

    runHook postInstall
  '';

  passthru.updateScript = nix-update-script { };

  meta = with lib; {
    description = "Discord client modification, focused on enhancing user and developer experience";
    longDescription = ''
      Moonlight is a ***passion project***—yet another Discord client mod—focused on providing a decent user
      and developer experience. Heavily inspired by hh3 (a private client mod) and the projects before it, namely EndPwn.
      All core code is original or used with permission from their respective authors where not copyleft.
    '';
    homepage = "https://moonlight-mod.github.io";
    changelog = "https://github.com/moonlight-mod/moonlight/blob/main/CHANGELOG.md";

    license = licenses.lgpl3;
    maintainers = with maintainers; [
      ilys
      donteatoreo
    ];
  };
})