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

discord: refactor; add client mod tests (#446990)

parents bbc9c143 9e846ebd
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
  stdenv,
  binaryName,
  desktopName,
  self,
  lib,
  undmg,
  makeWrapper,
@@ -116,5 +117,20 @@ stdenv.mkDerivation {
        lib.optionalString (!stdenv.buildPlatform.isDarwin) "pkgsCross.aarch64-darwin."
      }${pname} "$version" --file=./pkgs/applications/networking/instant-messengers/discord/default.nix --version-key=${branch}
    '';

    tests = {
      withVencord = self.override {
        withVencord = true;
      };
      withEquicord = self.override {
        withEquicord = true;
      };
      withMoonlight = self.override {
        withMoonlight = true;
      };
      withOpenASAR = self.override {
        withOpenASAR = true;
      };
    };
  };
}
+119 −84
Original line number Diff line number Diff line
{
  branch ? "stable",
  callPackage,
  fetchurl,
  lib,
  stdenv,
  discord,
  discord-ptb,
  discord-canary,
  discord-development,
}:
let
  versions =
    if stdenv.hostPlatform.isLinux then
      {
        stable = "0.0.111";
        ptb = "0.0.161";
        canary = "0.0.761";
        development = "0.0.89";
      }
    else
      {
        stable = "0.0.362";
        ptb = "0.0.192";
        canary = "0.0.867";
        development = "0.0.100";
      };
  version = versions.${branch};
  srcs = rec {
  variants = rec {
    x86_64-linux = {
      stable = fetchurl {
      discord = rec {
        version = "0.0.111";

        src = fetchurl {
          url = "https://stable.dl2.discordapp.net/apps/linux/${version}/discord-${version}.tar.gz";
          hash = "sha256-o4U6i223Agtbt1N9v0GO/Ivx68OQcX/N3mHXUX2gruA=";
        };
      ptb = fetchurl {

        branch = "stable";
        binaryName = desktopName;
        desktopName = "Discord";
        self = discord;
      };
      discord-ptb = rec {
        version = "0.0.161";

        src = fetchurl {
          url = "https://ptb.dl2.discordapp.net/apps/linux/${version}/discord-ptb-${version}.tar.gz";
          hash = "sha256-pDWOnj8tQK9runi/QzcvEFbNGCwAb/gISM9LrLoTzxM=";
        };
      canary = fetchurl {

        branch = "ptb";
        binaryName = "DiscordPTB";
        desktopName = "Discord PTB";
        self = discord-ptb;
      };
      discord-canary = rec {
        version = "0.0.761";

        src = fetchurl {
          url = "https://canary.dl2.discordapp.net/apps/linux/${version}/discord-canary-${version}.tar.gz";
          hash = "sha256-L3MIcrz/xj8zOb2QVXBrBCHGt4BdHhjwKpPZ4iClQYQ=";
        };
      development = fetchurl {

        branch = "canary";
        binaryName = "DiscordCanary";
        desktopName = "Discord Canary";
        self = discord-canary;
      };
      discord-development = rec {
        version = "0.0.89";

        src = fetchurl {
          url = "https://development.dl2.discordapp.net/apps/linux/${version}/discord-development-${version}.tar.gz";
          hash = "sha256-ZMsBR0LAISrM3dib8fehW/eZGkwSCinQF60jJG76O7M=";
        };

        branch = "development";
        binaryName = "DiscordDevelopment";
        desktopName = "Discord Development";
        self = discord-development;
      };
    };
    x86_64-darwin = {
      stable = fetchurl {
      discord = rec {
        version = "0.0.362";

        src = fetchurl {
          url = "https://stable.dl2.discordapp.net/apps/osx/${version}/Discord.dmg";
          hash = "sha256-DHe0WwJOB3mm1HbQwEOJ9NWqxzhOBQynhjJXYSNvA/k=";
        };
      ptb = fetchurl {

        branch = "stable";
        binaryName = desktopName;
        desktopName = "Discord";
        self = discord;
      };
      discord-ptb = rec {
        version = "0.0.192";

        src = fetchurl {
          url = "https://ptb.dl2.discordapp.net/apps/osx/${version}/DiscordPTB.dmg";
          hash = "sha256-AZ9enKJf6WZLELFLKrzeyAR/Q/pzD8SGvCPcInS8vsk=";
        };
      canary = fetchurl {

        branch = "ptb";
        binaryName = desktopName;
        desktopName = "Discord PTB";
        self = discord-ptb;
      };
      discord-canary = rec {
        version = "0.0.867";

        src = fetchurl {
          url = "https://canary.dl2.discordapp.net/apps/osx/${version}/DiscordCanary.dmg";
          hash = "sha256-67B2wZRZEOKutMPsrRlc96UZWShYLAgwOoF2/QzBgzE=";
        };
      development = fetchurl {

        branch = "canary";
        binaryName = desktopName;
        desktopName = "Discord Canary";
        self = discord-canary;
      };
      discord-development = rec {
        version = "0.0.100";

        src = fetchurl {
          url = "https://development.dl2.discordapp.net/apps/osx/${version}/DiscordDevelopment.dmg";
          hash = "sha256-PknNHr9txxp3+nO7FgHH7n04qx6p6Jzbs92/Hcfh13Y=";
        };

        branch = "development";
        binaryName = desktopName;
        desktopName = "Discord Development";
        self = discord-development;
      };
    };

    aarch64-darwin = x86_64-darwin;
    default = x86_64-linux; # Used for unsupported platforms, so we can return *something* there.
  };
  src =
    srcs.${stdenv.hostPlatform.system}.${branch}
      or (throw "${stdenv.hostPlatform.system} not supported on ${branch}");

  meta = {
    description = "All-in-one cross-platform voice and text chat for gamers";
@@ -86,43 +144,20 @@ let
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
  };
  package = if stdenv.hostPlatform.isLinux then ./linux.nix else ./darwin.nix;

  packages = (
    builtins.mapAttrs
      (
        _: value:
in
lib.genAttrs [ "discord" "discord-ptb" "discord-canary" "discord-development" ] (
  pname:
  let
    args = (variants.${stdenv.hostPlatform.system} or variants.default).${pname};
  in
  callPackage package (
          value
    args
    // {
            inherit src version branch;
      inherit pname;

      meta = meta // {
              mainProgram = value.binaryName;
        mainProgram = args.binaryName;
      };
    }
  )
)
      {
        stable = {
          pname = "discord";
          binaryName = "Discord";
          desktopName = "Discord";
        };
        ptb = rec {
          pname = "discord-ptb";
          binaryName = if stdenv.hostPlatform.isLinux then "DiscordPTB" else desktopName;
          desktopName = "Discord PTB";
        };
        canary = rec {
          pname = "discord-canary";
          binaryName = if stdenv.hostPlatform.isLinux then "DiscordCanary" else desktopName;
          desktopName = "Discord Canary";
        };
        development = rec {
          pname = "discord-development";
          binaryName = if stdenv.hostPlatform.isLinux then "DiscordDevelopment" else desktopName;
          desktopName = "Discord Development";
        };
      }
  );
in
packages.${branch}
+16 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
  meta,
  binaryName,
  desktopName,
  self,
  autoPatchelfHook,
  makeDesktopItem,
  lib,
@@ -260,5 +261,20 @@ stdenv.mkDerivation (finalAttrs: {
      version=$(echo $url | grep -oP '/\K(\d+\.){2}\d+')
      update-source-version ${pname} "$version" --file=./pkgs/applications/networking/instant-messengers/discord/default.nix --version-key=${branch}
    '';

    tests = {
      withVencord = self.override {
        withVencord = true;
      };
      withEquicord = self.override {
        withEquicord = true;
      };
      withMoonlight = self.override {
        withMoonlight = true;
      };
      withOpenASAR = self.override {
        withOpenASAR = true;
      };
    };
  };
})
+14 −5
Original line number Diff line number Diff line
@@ -6,6 +6,10 @@
  pnpm_10,
  stdenv,
  nix-update-script,
  discord,
  discord-ptb,
  discord-canary,
  discord-development,
  buildWebExtension ? false,
}:
stdenv.mkDerivation (finalAttrs: {
@@ -57,12 +61,17 @@ stdenv.mkDerivation (finalAttrs: {
    runHook postInstall
  '';

  passthru.updateScript = nix-update-script {
  passthru = {
    updateScript = nix-update-script {
      extraArgs = [
        "--version-regex"
        "^(\\d{4}-\\d{2}-\\d{2})$"
      ];
    };
    tests = lib.genAttrs' [ discord discord-ptb discord-canary discord-development ] (
      p: lib.nameValuePair p.pname p.tests.withEquicord
    );
  };

  meta = {
    description = "Other cutest Discord client mod";
+10 −1
Original line number Diff line number Diff line
@@ -5,6 +5,10 @@
  nodejs_22,
  fetchFromGitHub,
  nix-update-script,
  discord,
  discord-ptb,
  discord-canary,
  discord-development,
}:
stdenv.mkDerivation (finalAttrs: {
  pname = "moonlight";
@@ -57,7 +61,12 @@ stdenv.mkDerivation (finalAttrs: {
    runHook postInstall
  '';

  passthru.updateScript = nix-update-script { };
  passthru = {
    updateScript = nix-update-script { };
    tests = lib.genAttrs' [ discord discord-ptb discord-canary discord-development ] (
      p: lib.nameValuePair p.pname p.tests.withMoonlight
    );
  };

  meta = with lib; {
    description = "Discord client modification, focused on enhancing user and developer experience";
Loading