{ lib, pkgs, config, ... }: with lib; let cfg = config.programs.macchina; tomlFormat = pkgs.formats.toml {}; in { options.programs.macchina = { enable = mkEnableOption "macchina"; package = mkPackageOption pkgs "macchina" {}; config = mkOption { inherit (tomlFormat) type; default = {}; example = { theme = "Mezora"; show = [ "Kernel" "Machine" "OperatingSystem" "Resolution" "Uptime" "LocalIP" "Packages" "ProcessorLoad" "Memory" "Battery" ]; }; description = '' Macchina configuration. ''; }; themes = with types; mkOption { inherit (tomlFormat) type; default = {}; }; }; config = mkIf cfg.enable { home.packages = [cfg.package]; xdg.configFile = { "macchina/macchina.toml".source = tomlFormat.generate "macchina.toml" cfg.config; } // ( attrsets.concatMapAttrs (name: value: { "macchina/themes/${name}.toml".source = tomlFormat.generate "${name}.toml" value; }) cfg.themes ); }; }