{ lib, pkgs, config, ... }: let cfg = config.programs.emulationstation-de; in { imports = [ ./steam.nix ]; options.programs.emulationstation-de = with lib; { enable = mkEnableOption "EmulationStation Desktop Edition, a frontend for browsing and launching games from your multi-platform game collection"; package = mkOption { type = types.package; default = pkgs.emulationstation-de; }; nintendo.enable = mkEnableOption "Nintendo emulation support using melonDS"; }; config = let packages = [cfg.package] ++ (lib.optional cfg.nintendo.enable pkgs.melonDS); in lib.mkIf cfg.enable { environment.systemPackages = packages; programs.steam.extraPkgs = packages; nixpkgs.config.permittedInsecurePackages = [ "freeimage-unstable-2021-11-01" ]; }; }