new service! amdl

This commit is contained in:
Reid 2025-05-19 01:15:21 -07:00
parent 5c7720f462
commit 66ccec0f2c
Signed by: reidlab
GPG key ID: DAF5EAF6665839FD
11 changed files with 138 additions and 14 deletions

44
modules/services/amdl.nix Normal file
View file

@ -0,0 +1,44 @@
{ config, lib, pkgs, options, ... }:
with lib;
let
cfg = config.modules.services.amdl;
in {
options.modules.services.amdl = {
enable = mkEnableOption "enable amdl, an apple music download server";
port = mkOption {
type = types.int;
default = 3001;
};
domain = mkOption {
type = types.str;
default = "amdl.reidlab.pink";
};
};
config = mkIf cfg.enable {
services.amdl = {
enable = true;
stateDir = "/var/lib/${cfg.domain}";
config = {
server = {
port = cfg.port;
};
};
env = {
MEDIA_USER_TOKEN = lib.removeSuffix "\n" (builtins.readFile /etc/secrets/amdl/media_user_token);
WIDEVINE_CLIENT_ID = lib.removeSuffix "\n" (builtins.readFile /etc/secrets/amdl/widevine_client_id);
WIDEVINE_PRIVATE_KEY = lib.removeSuffix "\n" (builtins.readFile /etc/secrets/amdl/widevine_private_key);
};
};
services.nginx.virtualHosts."${cfg.domain}" = {
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://127.0.0.1:${toString cfg.port}";
};
};
};
}