From 3998c5f164f7c38616a9f73f9e5910136c9b75a5 Mon Sep 17 00:00:00 2001 From: KP64 Date: Sat, 28 Dec 2024 21:50:34 +0100 Subject: [PATCH] feat: Streaming & Torrenting --- hosts/rs/configuration.nix | 4 +++ services/media/default.nix | 9 ++++++ services/media/jellyfin.nix | 29 +++++++++++++++++ services/networking/default.nix | 1 + services/networking/i2p.nix | 56 +++++++++++++++++++++++++++++++++ 5 files changed, 99 insertions(+) create mode 100644 services/media/jellyfin.nix create mode 100644 services/networking/i2p.nix diff --git a/hosts/rs/configuration.nix b/hosts/rs/configuration.nix index 5daf2c5..8329b6f 100644 --- a/hosts/rs/configuration.nix +++ b/hosts/rs/configuration.nix @@ -109,6 +109,7 @@ services = { media = { immich.enable = true; + jellyfin.enable = true; redlib.enable = true; }; @@ -168,6 +169,8 @@ ]; networking = { + i2p.enable = true; + wireguard = let inherit (config.sops) secrets; @@ -259,6 +262,7 @@ "audio" "video" "tss" + "multimedia" ]; }; } diff --git a/services/media/default.nix b/services/media/default.nix index 43de0b9..c9b08c9 100644 --- a/services/media/default.nix +++ b/services/media/default.nix @@ -1,6 +1,15 @@ { imports = [ ./immich.nix + ./jellyfin.nix ./redlib.nix ]; + + users.groups.multimedia = { }; + + # TODO: This is for future *arr Services + systemd.tmpfiles.rules = [ + "d /data - - - - -" + "d /data/media 0770 - multimedia - -" + ]; } diff --git a/services/media/jellyfin.nix b/services/media/jellyfin.nix new file mode 100644 index 0000000..2d73ce2 --- /dev/null +++ b/services/media/jellyfin.nix @@ -0,0 +1,29 @@ +{ + config, + lib, + stable-pkgs, + ... +}: +let + cfg = config.services.media.jellyfin; +in +{ + options.services.media.jellyfin.enable = lib.mkEnableOption "Jellyfin"; + config = lib.mkMerge [ + { + # Unstable needs pipewire which has to + # compile from Source on aarch64-linux + services.jellyfin = { + inherit (cfg) enable; + openFirewall = true; + package = stable-pkgs.jellyfin; + group = "multimedia"; + }; + } + + (lib.mkIf config.isImpermanenceEnabled { + environment.persistence."/persist".directores = + lib.optional cfg.enable config.services.jellyfin.dataDir; + }) + ]; +} diff --git a/services/networking/default.nix b/services/networking/default.nix index 0bebce9..2a431ab 100644 --- a/services/networking/default.nix +++ b/services/networking/default.nix @@ -1,6 +1,7 @@ { imports = [ ./adguard.nix + ./i2p.nix ./wireguard.nix ]; } diff --git a/services/networking/i2p.nix b/services/networking/i2p.nix new file mode 100644 index 0000000..0661e09 --- /dev/null +++ b/services/networking/i2p.nix @@ -0,0 +1,56 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.services.networking.i2p; +in +{ + options.services.networking.i2p.enable = lib.mkEnableOption "I2p"; + + config = lib.mkMerge [ + (lib.mkIf cfg.enable { + environment.systemPackages = with pkgs; [ + xd + rqbit + transmission_4-gtk + ]; + + services.transmission = { + enable = true; + package = pkgs.transmission_4; + group = "multimedia"; + settings.rpc-bind-address = "0.0.0.0"; + openRPCPort = true; + openFirewall = true; + openPeerPorts = true; + # credentialsFile = config.sops.secrets."transmission/settings.json".path; + }; + + services.i2pd = { + enable = true; + address = "0.0.0.0"; + proto = { + http.enable = true; + httpProxy.enable = true; + socksProxy.enable = true; + sam.enable = true; + i2cp = { + enable = true; + address = "0.0.0.0"; + port = 7654; + }; + }; + }; + }) + + (lib.mkIf config.isImpermanenceEnabled { + environment.persistence."/persist".directories = lib.optionals cfg.enable [ + config.services.transmission.home + "/var/lib/i2pd" + ]; + }) + ]; +}