{ lib, pkgs, config, ... }: let inherit (lib) types mkIf mkEnableOption mkPackageOption mkOption ; cfg = config.programs.am2rlauncher; in { meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ]; options.programs.am2rlauncher = { enable = mkEnableOption "am2rlauncher"; package = mkPackageOption pkgs "am2rlauncher" { nullable = true; }; config = mkOption { type = with types; either str path; default = ""; example = '' ''; description = '' Config file for am2rlauncher in XML format. You can see the available options by modifying the settings in the GUI and looking at $XDG_CONFIG_HOME/AM2RLauncher/config.xml. ''; }; }; config = mkIf cfg.enable { assertions = [ (lib.hm.assertions.assertPlatform "programs.am2rlauncher" pkgs lib.platforms.linux) ]; home.packages = mkIf (cfg.package != null) [ cfg.package ]; xdg.configFile."AM2RLauncher/config.xml" = mkIf (cfg.config != "") { source = if lib.isPath cfg.config then cfg.config else pkgs.writeText "am2rlauncher-config.xml" cfg.config; }; }; }