{ lib, config, ... }:
let
  cfg = config.mods.unfree;
  mkPackages = mod: if cfg.${mod}.enable then cfg.${mod}.packages else [ ];

in {
  imports = [ ./steam.nix ./nvidia.nix ./minecraft.nix ./valheim.nix ];

  nixpkgs.config.allowUnfreePredicate = pkg:
    builtins.elem (lib.getName pkg) ((mkPackages "steam")
      ++ (mkPackages "minecraft") ++ (mkPackages "nvidia")
      ++ (mkPackages "valheim") ++ [ "stremio-shell" "stremio-server" ]);
}
