2024-05-20 16:27:01 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
2024-06-24 15:38:28 +00:00
|
|
|
cfg = config.aux.system.services.airsonic;
|
2024-05-20 16:27:01 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
2024-06-24 15:38:28 +00:00
|
|
|
aux.system.services.airsonic = {
|
2024-05-21 00:52:57 +00:00
|
|
|
autostart = lib.mkEnableOption (lib.mdDoc "Automatically starts Airsonic at boot.");
|
2024-05-20 16:27:01 +00:00
|
|
|
enable = lib.mkEnableOption (lib.mdDoc "Enables Airsonic Advanced media streaming service.");
|
|
|
|
home = lib.mkOption {
|
2024-05-21 13:22:03 +00:00
|
|
|
default = "";
|
2024-05-20 16:27:01 +00:00
|
|
|
type = lib.types.str;
|
|
|
|
description = "Where to store Airsonic's files";
|
|
|
|
};
|
2024-06-25 18:13:15 +00:00
|
|
|
domain = lib.mkOption {
|
|
|
|
default = "";
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "The root domain that Airsonic will be hosted on.";
|
|
|
|
example = "example.com";
|
|
|
|
};
|
|
|
|
url = lib.mkOption {
|
|
|
|
default = "";
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "The complete URL where Airsonic is hosted.";
|
|
|
|
example = "https://forgejo.example.com";
|
|
|
|
};
|
2024-05-20 16:27:01 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
2024-06-24 15:38:28 +00:00
|
|
|
aux.system.users.media.enable = true;
|
2024-05-20 16:27:01 +00:00
|
|
|
users.users.airsonic.extraGroups = [ "media" ];
|
|
|
|
|
|
|
|
services = {
|
2024-06-25 18:13:15 +00:00
|
|
|
nginx.virtualHosts."${cfg.url}" = {
|
|
|
|
useACMEHost = cfg.domain;
|
2024-05-20 16:27:01 +00:00
|
|
|
forceSSL = true;
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://127.0.0.1:4040";
|
|
|
|
proxyWebsockets = true;
|
|
|
|
extraConfig = "proxy_ssl_server_name on;";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
airsonic = {
|
|
|
|
enable = true;
|
|
|
|
war = "${
|
|
|
|
(pkgs.callPackage ../../packages/airsonic-advanced.nix { inherit lib; })
|
|
|
|
}/webapps/airsonic.war";
|
|
|
|
port = 4040;
|
|
|
|
jre = pkgs.jdk17;
|
|
|
|
jvmOptions = [
|
|
|
|
"-Dserver.use-forward-headers=true"
|
|
|
|
"-Xmx4G" # Increase Java heap size to 4GB
|
|
|
|
];
|
2024-05-24 03:50:42 +00:00
|
|
|
} // lib.optionalAttrs (cfg.home != "") { home = cfg.home; };
|
2024-05-20 16:27:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services = {
|
|
|
|
nginx.wants = [ config.systemd.services.airsonic.name ];
|
2024-05-21 00:52:57 +00:00
|
|
|
} // lib.optionalAttrs (!cfg.autostart) { airsonic.wantedBy = lib.mkForce [ ]; };
|
2024-05-20 16:27:01 +00:00
|
|
|
};
|
|
|
|
}
|