Added a (tiny) bit of modularity in the mediaserver module

This commit is contained in:
Julien Malka 2021-12-29 10:40:31 +01:00
parent 08df42e079
commit 8e4ddf4ef0
No known key found for this signature in database
GPG key ID: 3C68E13964FEA07F
6 changed files with 213 additions and 133 deletions

View file

@ -3,37 +3,51 @@ with lib;
let let
cfg = config.luj.jackett; cfg = config.luj.jackett;
port = 9117; port = 9117;
in { in
{
options.luj.jackett = { options.luj.jackett = {
enable = mkEnableOption "activate jackett service"; enable = mkEnableOption "activate jackett service";
user = mkOption {
type = types.str;
default = "jackett";
description = "User account under which Jackett runs.";
};
group = mkOption {
type = types.str;
default = "jackett";
description = "Group under which Jackett runs.";
};
nginx.enable = mkEnableOption "activate nginx"; nginx.enable = mkEnableOption "activate nginx";
nginx.subdomain = mkOption { nginx.subdomain = mkOption {
type = types.str; type = types.str;
}; };
}; };
config = mkIf cfg.enable ( config = mkIf cfg.enable (
mkMerge [{ mkMerge [{
services.jackett = { services.jackett = {
enable = true; enable = true;
user = "mediaserver"; user = cfg.user;
group = "mediaserver"; group = cfg.group;
};
}
(mkIf cfg.nginx.enable {
luj.nginx.enable = true;
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
}; };
}
}) (mkIf cfg.nginx.enable {
]); luj.nginx.enable = true;
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
})]);

View file

@ -3,10 +3,25 @@ with lib;
let let
cfg = config.luj.jellyfin; cfg = config.luj.jellyfin;
port = 8096; port = 8096;
in { in
{
options.luj.jellyfin = { options.luj.jellyfin = {
enable = mkEnableOption "activate jellyfin service"; enable = mkEnableOption "activate jellyfin service";
user = mkOption {
type = types.str;
default = "jellyfin";
description = "User account under which Jellyfin runs.";
};
group = mkOption {
type = types.str;
default = "jellyfin";
description = "Group under which Jellyfin runs.";
};
nginx.enable = mkEnableOption "activate nginx"; nginx.enable = mkEnableOption "activate nginx";
nginx.subdomain = mkOption { nginx.subdomain = mkOption {
type = types.str; type = types.str;
@ -15,26 +30,24 @@ in {
config = mkIf cfg.enable ( config = mkIf cfg.enable (
mkMerge [{ mkMerge [{
services.jellyfin = { services.jellyfin = {
enable = true; enable = true;
user = "mediaserver"; user = cfg.user;
group = "mediaserver"; group = cfg.group;
package = pkgs.jellyfin;
};
}
(mkIf cfg.nginx.enable {
luj.nginx.enable = true;
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
}; };
}
}) (mkIf cfg.nginx.enable {
]); luj.nginx.enable = true;
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
})]);

View file

@ -23,30 +23,40 @@ in {
luj.sonarr = { luj.sonarr = {
enable = true; enable = true;
user = "mediaserver";
group = "mediaserver";
nginx.enable = true; nginx.enable = true;
nginx.subdomain = "series"; nginx.subdomain = "series";
}; };
luj.radarr = { luj.radarr = {
enable = true; enable = true;
user = "mediaserver";
group = "mediaserver";
nginx.enable = true; nginx.enable = true;
nginx.subdomain = "films"; nginx.subdomain = "films";
}; };
luj.jellyfin = { luj.jellyfin = {
enable = true; enable = true;
user = "mediaserver";
group = "mediaserver";
nginx.enable = true; nginx.enable = true;
nginx.subdomain = "tv"; nginx.subdomain = "tv";
}; };
luj.jackett = { luj.jackett = {
enable = true; enable = true;
user = "mediaserver";
group = "mediaserver";
nginx.enable = true; nginx.enable = true;
nginx.subdomain = "jackett"; nginx.subdomain = "jackett";
}; };
luj.transmission = { luj.transmission = {
enable = true; enable = true;
user = "mediaserver";
group = "mediaserver";
nginx.enable = true; nginx.enable = true;
nginx.subdomain = "downloads"; nginx.subdomain = "downloads";
}; };

View file

@ -3,37 +3,52 @@ with lib;
let let
cfg = config.luj.radarr; cfg = config.luj.radarr;
port = 7878; port = 7878;
in { in
{
options.luj.radarr = { options.luj.radarr = {
enable = mkEnableOption "activate radarr service"; enable = mkEnableOption "activate radarr service";
user = mkOption {
type = types.str;
default = "radarr";
description = "User account under which Radarr runs.";
};
group = mkOption {
type = types.str;
default = "radarr";
description = "Group under which Radarr runs.";
};
nginx.enable = mkEnableOption "activate nginx"; nginx.enable = mkEnableOption "activate nginx";
nginx.subdomain = mkOption { nginx.subdomain = mkOption {
type = types.str; type = types.str;
}; };
}; };
config = mkIf cfg.enable ( config = mkIf cfg.enable (
mkMerge [{ mkMerge [{
services.radarr = { services.radarr = {
enable = true; enable = true;
user = "mediaserver"; user = cfg.user;
group = "mediaserver"; group = cfg.group;
};
}
(mkIf cfg.nginx.enable {
luj.nginx.enable = true;
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
}; };
}
}) (mkIf cfg.nginx.enable {
]); luj.nginx.enable = true;
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
})]);

View file

@ -3,37 +3,52 @@ with lib;
let let
cfg = config.luj.sonarr; cfg = config.luj.sonarr;
port = 8989; port = 8989;
in { in
{
options.luj.sonarr = { options.luj.sonarr = {
enable = mkEnableOption "activate sonarr service"; enable = mkEnableOption "activate sonarr service";
user = mkOption {
type = types.str;
default = "sonarr";
description = "User account under which Sonarr runs.";
};
group = mkOption {
type = types.str;
default = "sonarr";
description = "Group under which Sonarr runs.";
};
nginx.enable = mkEnableOption "activate nginx"; nginx.enable = mkEnableOption "activate nginx";
nginx.subdomain = mkOption { nginx.subdomain = mkOption {
type = types.str; type = types.str;
}; };
}; };
config = mkIf cfg.enable ( config = mkIf cfg.enable (
mkMerge [{ mkMerge [{
services.sonarr = { services.sonarr = {
enable = true; enable = true;
user = "mediaserver"; user = cfg.user;
group = "mediaserver"; group = cfg.group;
};
}
(mkIf cfg.nginx.enable {
luj.nginx.enable = true;
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
}; };
}
}) (mkIf cfg.nginx.enable {
]); luj.nginx.enable = true;
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
})]);

View file

@ -3,53 +3,66 @@ with lib;
let let
cfg = config.luj.transmission; cfg = config.luj.transmission;
port = 9091; port = 9091;
in { in
{
options.luj.transmission = { options.luj.transmission = {
enable = mkEnableOption "activate transmission service"; enable = mkEnableOption "activate transmission service";
user = mkOption {
type = types.str;
default = "transmission";
description = "User account under which transmission runs.";
};
group = mkOption {
type = types.str;
default = "transmission";
description = "Group under which Transmission runs.";
};
nginx.enable = mkEnableOption "activate nginx"; nginx.enable = mkEnableOption "activate nginx";
nginx.subdomain = mkOption { nginx.subdomain = mkOption {
type = types.str; type = types.str;
}; };
}; };
config = mkIf cfg.enable ( config = mkIf cfg.enable (
mkMerge [{ mkMerge [{
sops.secrets.transmission = {
sops.secrets.transmission = { owner = cfg.user;
owner = "mediaserver"; format = "binary";
format = "binary"; sopsFile = ../../secrets/transmission-login;
sopsFile = ../../secrets/transmission-login;
};
services.transmission = {
enable = true;
user = "mediaserver";
group = "mediaserver";
credentialsFile = "/run/secrets/transmission";
downloadDirPermissions = "770";
settings = {
rpc-port = 9091;
download-dir = "/home/mediaserver/downloads/complete/";
incomplete-dir = "/home/mediaserver/downloads/incomplete/";
incomplete-dir-enable = true;
}; };
};
}
(mkIf cfg.nginx.enable { services.transmission = {
luj.nginx.enable = true; enable = true;
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = { user = cfg.user;
enableACME = true; group = cfg.group;
forceSSL = true; credentialsFile = "/run/secrets/transmission";
locations."/" = { downloadDirPermissions = "770";
proxyPass = "http://localhost:${toString port}"; settings = {
rpc-port = 9091;
download-dir = "/home/mediaserver/downloads/complete/";
incomplete-dir = "/home/mediaserver/downloads/incomplete/";
incomplete-dir-enable = true;
}; };
}; };
}
}) (mkIf cfg.nginx.enable {
]); luj.nginx.enable = true;
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
})]);