Only allow certain unfree packages in `flake.nix`?

I was wondering if it’s possible to use this within my flake:

{
  allowUnfreePredicate = pkg:
    builtins.elem (
      lib.getName pkg
    ) (
      map lib.getName [
        pkgs.corefonts
        pkgs.discord
        pkgs.jetbrains.idea-ultimate
        pkgs.spotify-unwrapped
        pkgs.unrar
      ]
    );
}

I tried this, but it’s saying one of the binaries included within epkowa (iscan-gt-f720-bundle) isn’t allowed.

channels-config.allowUnfreePredicate = pkg:
builtins.elem (
    inputs.nixpkgs.lib.getName pkg
) (
    builtins.map inputs.nixpkgs.lib.getName [
        inputs.nixpkgs.legacyPackages.x86_64-linux.epkowa
        inputs.nixpkgs.legacyPackages.x86_64-linux.steam
    ]
);

If this is possible, I’d also much appreciate any suggestions on cleaning it up.