{ config, pkgs, lib, mkDomain, ... }:
{
  # Polaris
  # Self-host your music collection, and access it from any computer and mobile device

  #disabledModules = [ "services/misc/polaris.nix" ];
  #imports = [ "${inputs.unstable}/nixos/modules/services/misc/polaris.nix" ];

  services.polaris = {
    enable = true;
    #user = "pbsds";
    #group = "users";
    port = 7890;
    package = pkgs.unstable.polaris;
    settings = {
      settings.reindex_every_n_seconds = 7*24*60*60; # weekly, default is 1800, i.e. hourly
      settings.album_art_pattern =
        "([Cc]over|COVER|[Ff]older|FOLDER|[Ff]ront|FRONT)\.(jpeg|JPEG|jpg|JPG|png|PNG|bmp|BMP|gif|GIF)";
        #"(?i)(cover|folder|front)\.(jpeg|jpg|png|bmp|gif)";
      mount_dirs = [
        { name = "Albums";    source = "/mnt/reidun/Music/Albums"; }
        { name = "dojin.co";  source = "/mnt/reidun/Music/dojin.co"; }
        { name = "Vocaloid";  source = "/mnt/reidun/Music/Vocaloid"; }
        { name = "Touhou";    source = "/mnt/reidun/Music/Touhou"; }
        { name = "OST";       source = "/mnt/reidun/Music/OST"; }
        { name = "Kancolle";  source = "/mnt/reidun/Music/Kancolle"; }
        { name = "Downloads"; source = "/mnt/reidun/Downloads/music"; }
      ];
    };
  };
  services.nginx.virtualHosts.${mkDomain "polaris"} = lib.mkIf config.services.polaris.enable {
    forceSSL = true; # addSSL = true;
    enableACME = true; #useACMEHost = acmeDomain;
    locations."/" = {
      proxyPass = "http://127.0.0.1:${toString config.services.polaris.port}";
      proxyWebsockets = true;
    };
  };

}
