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}";
};
};
};
}

View file

@ -6,6 +6,10 @@ let
in {
options.modules.services.forgejo = {
enable = mkEnableOption "enable forgejo, a lightweight git server";
port = mkOption {
type = types.int;
default = 3000;
};
domain = mkOption {
type = types.str;
default = "git.reidlab.pink";
@ -26,6 +30,7 @@ in {
INSTALL_LOCK = true;
PASSWORD_HASH_ALGO = "argon2";
PASSWORD_CHECK_PWN = true;
REVERSE_PROXY_TRUSTED_PROXIES = "127.0.0.0/8,::1/128";
};
"ui.meta" = {
AUTHOR = "reidlab";
@ -33,7 +38,8 @@ in {
};
"server" = {
DOMAIN = cfg.domain;
PROTOCOL = "http+unix";
PROTOCOL = "http";
HTTP_PORT = cfg.port;
ROOT_URL = "https://${cfg.domain}/";
};
"repository" = {
@ -60,7 +66,7 @@ in {
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://unix:${config.services.forgejo.settings.server.HTTP_ADDR}";
proxyPass = "http://127.0.0.1:${toString cfg.port}";
extraConfig = ''
client_max_body_size 512M;
'';

View file

@ -16,15 +16,15 @@ in {
};
grafanaPort = mkOption {
type = types.int;
default = 3000;
default = 2000;
};
promtailPort = mkOption {
type = types.int;
default = 3001;
default = 2001;
};
lokiPort = mkOption {
type = types.int;
default = 3002;
default = 2002;
};
prometheusPort = mkOption {
type = types.int;

View file

@ -5,10 +5,7 @@ let
cfg = config.modules.services.mysql;
in {
options.modules.services.mysql = {
enable = mkOption {
type = types.bool;
default = false;
};
enable = mkEnableOption "enable mysql, a relational database management system";
};
config = mkIf cfg.enable {

View file

@ -6,6 +6,14 @@ let
in {
options.modules.services.nginx-config = {
enable = mkEnableOption "enable and configure nginx, a high performance web server";
port = mkOption {
type = types.int;
default = 80;
};
sslPort = mkOption {
type = types.int;
default = 443;
};
};
config = mkIf cfg.enable {
@ -19,6 +27,9 @@ in {
services.nginx = {
enable = true;
defaultHTTPListenPort = cfg.port;
defaultSSLListenPort = cfg.sslPort;
recommendedTlsSettings = true;
recommendedOptimisation = true;
recommendedGzipSettings = true;