{ pkgs, ... }:
let
  # krisp-patcher.py courtesy of https://github.com/sersorrel/sys
  patch-krisp = pkgs.writers.writePython3 "krisp-patcher" {
    libraries = with pkgs.python3Packages; [
      capstone
      pyelftools
    ];
    # Ignore syntax checker error codes that affect krisp-patcher.py
    flakeIgnore = [
      "E501"
      "F403"
      "F405"
    ];
  } (builtins.readFile ./krisp-patcher.py);
  binaryName = "Discord";
  node_module = "\\$HOME/.config/discord/${pkgs.discord.version}/modules/discord_krisp/discord_krisp.node";
in
pkgs.discord.overrideAttrs (previousAttrs: {
  postInstall = previousAttrs.postInstall + ''
    wrapProgramShell $out/opt/${binaryName}/${binaryName} \
    --run "${patch-krisp} ${node_module}"
  '';
  passthru = removeAttrs previousAttrs.passthru [ "updateScript" ];
  meta = {
    nyx.bypassLicense = true;
  }
  // previousAttrs.meta;
})
