I use nixpkgs as source of all my packages and I sometimes have to work with unfree packages. You can either allow all unfree packages or do it selectively. However the default error about it doesn't say how to fix it in flakes.

So let's see!

Allowing all unfree packages

In your flake.nix you probably have something similar :

pkgs = import nixpkgs {
  config.allowUnfree = true;
  inherit system;
};

This is nice but I like to keep my config tidy and know when I use something that's actually unfree. Thus I use a selective configuration for unfree packages.

Selectively allowing unfree packages

pkgs = import nixpkgs {
  config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "discord" "slack" ];
  inherit system;
};

And that's it !

Note about Nixpkgs unstable

Note that discord is quite a moving target that you probably use it from nixpkgs unstable. It's also not that rare to have broken packages on unstable. Like, you know, it's not stable.

You can then use the following :

pkgs = import nixpkgs {
  config = {
    allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "discord" "slack" ];
    allowBroken = true;
  };
  inherit system;
};