{ config
, lib
, pkgs
, ...
}:

with lib;
let
  cfg = config.my.programs.himalaya;
  toml = pkgs.formats.toml { };
in
{
  options.my.programs.himalaya.enable = mkEnableOption "himalaya";
  options.my.programs.himalaya.package = mkPackageOption pkgs "himalaya" { };
  options.my.programs.himalaya.settings = mkOption {
    inherit (toml) type;
    default = { };
    apply = toml.generate "config.toml";
  };


  config = mkIf cfg.enable {
    home-manager.users.moritz.xdg.configFile."himalaya/config.toml".source = cfg.settings;
    home-manager.users.moritz.home.packages = [ cfg.package ];
    age.secrets.email = {
      file = ../../secrets/email.age;
      owner = "1000";
    };
  };
}
