Refactored modules

This commit is contained in:
Julien Malka 2021-12-04 13:13:13 +01:00
parent 56c0af44ca
commit f4f5d6e869
16 changed files with 368 additions and 24 deletions

View file

@ -0,0 +1,39 @@
{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.luj.jackett;
port = 9117;
in {
options.luj.jackett = {
enable = mkEnableOption "activate jackett service";
nginx.enable = mkEnableOption "activate nginx";
nginx.subdomain = mkOption {
type = types.str;
};
};
config = mkIf cfg.enable (
mkMerge [{
services.jackett = {
enable = true;
};
networking.firewall = { allowedTCPPorts = [ port ]; };
}
(mkIf cfg.nginx.enable {
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
})
]);
}

View file

@ -0,0 +1,41 @@
{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.luj.jellyfin;
port = 8096;
in {
options.luj.jellyfin = {
enable = mkEnableOption "activate jellyfin service";
nginx.enable = mkEnableOption "activate nginx";
nginx.subdomain = mkOption {
type = types.str;
};
};
config = mkIf cfg.enable (
mkMerge [{
services.jellyfin = {
enable = true;
group = "tv";
package = pkgs.jellyfin;
};
networking.firewall = { allowedTCPPorts = [ port ]; };
}
(mkIf cfg.nginx.enable {
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
})
]);
}

View file

@ -0,0 +1,46 @@
{ lib, pkgs, config, ... }:
with lib;
let cfg = config.luj.mediaserver;
in {
options.luj.mediaserver = {
enable = mkEnableOption "enable the mediaserver";
};
config = mkIf cfg.enable {
luj.nginx.enable = true;
luj.nginx.email = "julien.malka@me.com";
luj.sonarr = {
enable = true;
nginx.enable = true;
nginx.subdomain = "series";
};
luj.radarr = {
enable = true;
nginx.enable = true;
nginx.subdomain = "films";
};
luj.jellyfin = {
enable = true;
nginx.enable = true;
nginx.subdomain = "tv";
};
luj.jackett = {
enable = true;
nginx.enable = true;
nginx.subdomain = "jackett";
};
luj.transmission = {
enable = true;
nginx.enable = true;
nginx.subdomain = "downloads";
};
};
}

30
modules/nginx/default.nix Normal file
View file

@ -0,0 +1,30 @@
{ lib, pkgs, config, ... }:
with lib;
let cfg = config.luj.nginx;
in {
options.luj.nginx = {
enable = mkEnableOption "activate nginx service";
email = mkOption {
type = types.str;
};
};
config = mkIf cfg.enable {
security.acme.email = "${cfg.email}";
security.acme.acceptTerms = true;
services.nginx = {
enable = true;
recommendedOptimisation = true;
recommendedTlsSettings = true;
clientMaxBodySize = "128m";
commonHttpConfig = ''
server_names_hash_bucket_size 128;
'';
};
};
}

View file

@ -0,0 +1,43 @@
{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.luj.radarr;
port = 7878;
in {
options.luj.radarr = {
enable = mkEnableOption "activate radarr service";
nginx.enable = mkEnableOption "activate nginx";
nginx.subdomain = mkOption {
type = types.str;
};
};
config = mkIf cfg.enable (
mkMerge [{
services.radarr = {
enable = true;
#user = "transmission";
#group = "transmission";
#dataDir = "/var/lib/sonarr/.config/NzbDrone";
group = "tv";
};
networking.firewall = { allowedTCPPorts = [ port ]; };
}
(mkIf cfg.nginx.enable {
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
})
]);
}

View file

@ -0,0 +1,43 @@
{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.luj.sonarr;
port = 8989;
in {
options.luj.sonarr = {
enable = mkEnableOption "activate sonarr service";
nginx.enable = mkEnableOption "activate nginx";
nginx.subdomain = mkOption {
type = types.str;
};
};
config = mkIf cfg.enable (
mkMerge [{
services.sonarr = {
enable = true;
#user = "transmission";
#group = "transmission";
#dataDir = "/var/lib/sonarr/.config/NzbDrone";
group = "tv";
};
networking.firewall = { allowedTCPPorts = [ port ]; };
}
(mkIf cfg.nginx.enable {
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
})
]);
}

View file

@ -0,0 +1,48 @@
{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.luj.transmission;
port = 9091;
in {
options.luj.transmission = {
enable = mkEnableOption "activate transmission service";
nginx.enable = mkEnableOption "activate nginx";
nginx.subdomain = mkOption {
type = types.str;
};
};
config = mkIf cfg.enable (
mkMerge [{
services.transmission = {
enable = true;
group = "tv";
downloadDirPermissions = "774";
settings = {
rpc-port = 9091;
download-dir = "/home/transmission/Downloads/";
incomplete-dir = "/home/transmission/Incomplete/";
incomplete-dir-enable = true;
};
};
networking.firewall = { allowedTCPPorts = [ port ]; };
}
(mkIf cfg.nginx.enable {
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
})
]);
}