{
  lib,
  pkgs,
  config,
  ...
}:
with lib;
{
  options = {
    glance = {
      enable = mkEnableOption "enables glance";
      port = lib.mkOption {
        type = lib.types.int;
        default = 8857;
        description = "The port glance listens on.";
      };
      host = mkOption {
        type = types.str;
        defaultText = literalExpression "127.0.0.1";
        description = "The hostname that glance binds to";
      };
      domain = mkOption {
        type = types.str;
        defaultText = literalExpression "home.wastring.com";
        description = "The hostname that glance binds to";
      };
    };
  };
  config = mkMerge [
    (mkIf config.glance.enable {
      services.glance = {
        enable = true;

        settings = {
          theme = {
            background-color = "240 21 15";
            contrast-multiplier = 1.2;
            primary-color = "217 92 83";
            positive-color = "115 54 76";
            negative-color = "347 70 65";
          };
          server = {
            host = config.glance.host;
            port = config.glance.port;
          };
          pages = [
            {
              name = "Home";
              columns = [
                {
                  size = "small";
                  widgets = [
                    { type = "calendar"; }
                  ];
                }
                {
                  size = "full";
                  widgets = [
                    {
                      type = "videos";
					  style = "vertical-list";
                      channels = [
                        "UCwHwDuNd9lCdA7chyyquDXw"
                        "UC7YOGHUfC1Tb6E4pudI9STA"
                        "UCs76MNovGkuNYNZCmrxcb3Q"
                      ];
                    }
                  ];
                }
                {
                  size = "small";
                  widgets = [
                    {
                      type = "weather";
                      location = "Malmö, Sweden";
                    }
                  ];
                }
              ];
            }
          ];
        };
      };
      services.nginx.virtualHosts.${config.glance.domain} = {
        forceSSL = true;
        enableACME = true;
        locations."/" = {
          proxyPass = "http://${toString config.glance.host}:${toString config.glance.port}";
          proxyWebsockets = true;
        };
      };
    })
  ];

}
