Added NAS Suite
All checks were successful
/ Check Nix Flake (push) Successful in 2m4s

This commit is contained in:
Matthias 2025-02-22 02:45:49 +01:00
parent 27b57e4949
commit 8a73af6a7c
Signed by: kb01
SSH key fingerprint: SHA256:kv2GYUy1MZEqusYnS+Y9nMgrpv77jhm+3kknl3UGV1k
6 changed files with 147 additions and 2 deletions

View file

@ -21,7 +21,6 @@ in
}; };
# Configure Reverse-Proxy # Configure Reverse-Proxy
services.traefik-proxy.enable = true;
services.traefik.dynamicConfigOptions = { services.traefik.dynamicConfigOptions = {
http.services.nix-cache.loadBalancer.servers = [ { url = "http://${config.services.nix-serve.bindAddress}:${toString config.services.nix-serve.port}/"; } ]; http.services.nix-cache.loadBalancer.servers = [ { url = "http://${config.services.nix-serve.bindAddress}:${toString config.services.nix-serve.port}/"; } ];
http.routers.nix-cache.entrypoints = "websecure"; http.routers.nix-cache.entrypoints = "websecure";

View file

@ -14,7 +14,9 @@ in
}; };
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf (cfg.enable ||
config.services.binary-cache.enable ||
config.suites.nas.media.enable) {
services.traefik = { services.traefik = {
enable = true; enable = true;
staticConfigOptions = { staticConfigOptions = {

View file

@ -0,0 +1,59 @@
{
inputs,
config,
lib,
pkgs,
system,
...
}:
let
cfg = config.suites.nas;
in
{
imports = [
./jellyfin.nix
./kavita.nix
];
options.suites.nas.enable = lib.mkOption {
type = with lib.types; uniq bool;
default = false;
description = "Enable Preconfigured NAS Config";
};
options.suites.nas.domain = lib.mkOption {
type = with lib.types; string;
default = "localhost";
description = "NAS Reachable Domain Name";
};
options.suites.nas.media.enable = lib.mkOption {
type = with lib.types; uniq bool;
default = true;
description = "Enable Media Servers";
};
options.suites.nas.media.folder = lib.mkOption {
type = with lib.types; str;
default = "/home/media/media";
description = "Media Root Directory";
};
# Media Config
config = lib.mkIf (cfg.enable && cfg.media.enable) {
# Media Defaults
suites.nas.media.jellyfin.enable = true;
suites.nas.media.kavita.enable = false;
# Create Media User
users.groups.media = {};
users.users.media = {
isSystemUser = true;
createHome = true;
description = "Media User";
group = "media";
home = "/home/media";
};
};
}

View file

@ -0,0 +1,41 @@
{
inputs,
config,
lib,
pkgs,
system,
...
}:
let
cfg = config.suites.nas.media.jellyfin;
in
{
options.suites.nas.media.jellyfin.enable = lib.mkOption {
type = with lib.types; uniq bool;
default = false;
description = "Enable Preconfigured Jellyfin Config";
};
options.suites.nas.media.jellyfin.subdomain = lib.mkOption {
type = with lib.types; string;
default = "watch";
description = "Subdomain for Jellyfin Server";
};
config = lib.mkIf (cfg.enable) {
services.jellyfin.enable = true;
services.jellyfin.user = "media";
# Configure Reverse-Proxy
services.traefik.dynamicConfigOptions = {
http.services.jellyfin.loadBalancer.servers = [ { url = "http://localhost:8096/"; } ];
http.routers.jellyfin.entrypoints = "websecure";
http.routers.jellyfin.tls = true;
#http.routers.jellyfin.tls.certresolver = "letsencrypt";
http.routers.jellyfin.rule = "Host(`${cfg.subdomain}.${config.suites.nas.domain}`)";
http.routers.jellyfin.service = "jellyfin";
};
};
}

View file

@ -0,0 +1,42 @@
{
inputs,
config,
lib,
pkgs,
system,
...
}:
let
cfg = config.suites.nas.media.kavita;
in
{
options.suites.nas.media.kavita.enable = lib.mkOption {
type = with lib.types; uniq bool;
default = false;
description = "Enable Preconfigured kavita Config";
};
options.suites.nas.media.kavita.subdomain = lib.mkOption {
type = with lib.types; string;
default = "read";
description = "Kavita Subdomain";
};
config = lib.mkIf (cfg.enable) {
services.kavita.enable = true;
services.kavita.user = "media";
services.kavita.tokenKeyFile = "/home/media/secrets/kavita-secret";
# Configure Reverse-Proxy
services.traefik.dynamicConfigOptions = {
http.services.kavita.loadBalancer.servers = [ { url = "http://localhost:5000/"; } ];
http.routers.kavita.entrypoints = "websecure";
http.routers.kavita.tls = true;
#http.routers.kavita.tls.certresolver = "letsencrypt";
http.routers.kavita.rule = "Host(`${cfg.subdomain}.${config.suites.nas.domain}`)";
http.routers.kavita.service = "kavita";
};
};
}

View file

@ -15,6 +15,8 @@
"electron-27.3.11" "electron-27.3.11"
]; ];
# NAS Test-Config
suites.nas.enable = false;
# Networking # Networking
networking.hostName = "Ohybke"; networking.hostName = "Ohybke";