cleanup
This commit is contained in:
@@ -4,43 +4,54 @@
|
||||
namespace,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.${namespace}.services.your_spotify;
|
||||
inherit (lib.${namespace}) mkOpt mkModule;
|
||||
name = "your-spotify";
|
||||
cfg = config.${namespace}.services.${name};
|
||||
in
|
||||
{
|
||||
imports = [ ./options.nix ];
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
virtualisation.oci-containers.containers."${cfg.name}-server" = {
|
||||
autoStart = true;
|
||||
image = cfg.imageServer;
|
||||
volumes = [ "${cfg.configPath}:/root/.your-spotify" ];
|
||||
ports = [ "${cfg.portServer}:8080" ];
|
||||
dependsOn = [ "mongo" ];
|
||||
environment = {
|
||||
PUID = cfg.puid;
|
||||
PGID = cfg.pgid;
|
||||
TZ = cfg.timeZone;
|
||||
API_ENDPOINT = "https://your-spotify-server.mjallen.dev";
|
||||
CLIENT_ENDPOINT = "https://your-spotify.mjallen.dev";
|
||||
SPOTIFY_PUBLIC = "e270589d72a6494680a17d325af8670d";
|
||||
SPOTIFY_SECRET = "423cb7b69fe8486e89eccd01e0c22924";
|
||||
MONGO_ENDPOINT = "mongodb://10.0.1.3:27017";
|
||||
imports = [
|
||||
(mkModule {
|
||||
inherit config name;
|
||||
description = "Your Spotify — self-hosted Spotify stats";
|
||||
options = {
|
||||
serverPort = mkOpt lib.types.int 7777 "Port for the API server container";
|
||||
webPort = mkOpt lib.types.int 7778 "Port for the web client container";
|
||||
imageServer = mkOpt lib.types.str "yooooomi/your_spotify_server" "Server OCI image";
|
||||
imageWeb = mkOpt lib.types.str "yooooomi/your_spotify_client" "Web client OCI image";
|
||||
};
|
||||
};
|
||||
moduleConfig = {
|
||||
virtualisation.oci-containers.containers."${name}-server" = {
|
||||
autoStart = true;
|
||||
image = cfg.imageServer;
|
||||
volumes = [ "${cfg.configDir}:/root/.your-spotify" ];
|
||||
ports = [ "${toString cfg.serverPort}:8080" ];
|
||||
dependsOn = [ "mongo" ];
|
||||
environment = {
|
||||
PUID = cfg.puid;
|
||||
PGID = cfg.pgid;
|
||||
TZ = cfg.timeZone;
|
||||
API_ENDPOINT = "https://your-spotify-server.mjallen.dev";
|
||||
CLIENT_ENDPOINT = "https://your-spotify.mjallen.dev";
|
||||
# TODO: move Spotify API keys to sops secrets
|
||||
SPOTIFY_PUBLIC = "e270589d72a6494680a17d325af8670d";
|
||||
SPOTIFY_SECRET = "423cb7b69fe8486e89eccd01e0c22924";
|
||||
MONGO_ENDPOINT = "mongodb://10.0.1.3:27017";
|
||||
};
|
||||
};
|
||||
|
||||
virtualisation.oci-containers.containers."${cfg.name}-web" = {
|
||||
autoStart = true;
|
||||
image = cfg.imageWeb;
|
||||
ports = [ "${cfg.portWeb}:3000" ];
|
||||
environment = {
|
||||
PUID = cfg.puid;
|
||||
PGID = cfg.pgid;
|
||||
TZ = cfg.timeZone;
|
||||
API_ENDPOINT = "https://your-spotify-server.mjallen.dev";
|
||||
virtualisation.oci-containers.containers."${name}-web" = {
|
||||
autoStart = true;
|
||||
image = cfg.imageWeb;
|
||||
ports = [ "${toString cfg.webPort}:3000" ];
|
||||
environment = {
|
||||
PUID = cfg.puid;
|
||||
PGID = cfg.pgid;
|
||||
TZ = cfg.timeZone;
|
||||
API_ENDPOINT = "https://your-spotify-server.mjallen.dev";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
{ lib, namespace, ... }:
|
||||
with lib;
|
||||
{
|
||||
options.${namespace}.services.your_spotify = {
|
||||
enable = mkEnableOption "your_spotify docker service";
|
||||
|
||||
autoStart = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
|
||||
portServer = mkOption {
|
||||
type = types.str;
|
||||
default = "7777";
|
||||
};
|
||||
|
||||
portWeb = mkOption {
|
||||
type = types.str;
|
||||
default = "7778";
|
||||
};
|
||||
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
default = "your_spotify";
|
||||
};
|
||||
|
||||
imageServer = mkOption {
|
||||
type = types.str;
|
||||
default = "yooooomi/your_spotify_server";
|
||||
};
|
||||
|
||||
imageWeb = mkOption {
|
||||
type = types.str;
|
||||
default = "yooooomi/your_spotify_client";
|
||||
};
|
||||
|
||||
configPath = mkOption {
|
||||
type = types.str;
|
||||
default = "/var/lib/your-spotify";
|
||||
};
|
||||
|
||||
puid = mkOption {
|
||||
type = types.str;
|
||||
default = "911";
|
||||
};
|
||||
|
||||
pgid = mkOption {
|
||||
type = types.str;
|
||||
default = "100";
|
||||
};
|
||||
|
||||
timeZone = mkOption {
|
||||
type = types.str;
|
||||
default = "UTC";
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user