{ config, lib, this, ... }: with lib; let cfg = config.nixfiles.modules.common.xdg; in { options.nixfiles.modules.common.xdg.defaultApplications = mkOption { description = "Default applications."; type = with types; attrsOf (listOf str); default = { }; }; config = { xdg.portal = mkIf this.isHeadful { enable = true; }; hm.xdg = mkMerge [ (with cfg; { enable = true; inherit cacheHome; inherit configHome; inherit dataHome; inherit stateHome; inherit userDirs; }) (mkIf this.isHeadful { mimeApps = { enable = true; defaultApplications = mkMerge ( mapAttrsToList (n: v: genAttrs v (_: [ "${n}.desktop" ])) cfg.defaultApplications ); }; }) ]; }; }