homepage: jellyfin init
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
let cfg = config.my.servers.audiobookshelf;
|
||||
in {
|
||||
options.my.servers.audiobookshelf =
|
||||
setup.mkServerOptions "audiobookshelf" "audiobooks" 5687;
|
||||
setup.mkOptions "audiobookshelf" "audiobooks" 5687;
|
||||
config = lib.mkIf config.my.servers.audiobookshelf.enable {
|
||||
services = {
|
||||
audiobookshelf = {
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
{ lib, config, ... }:
|
||||
|
||||
let
|
||||
mkServerOptions = name: subdomain: port: {
|
||||
mkOptions = name: subdomain: port: {
|
||||
enable = lib.mkEnableOption "enable";
|
||||
enableCron = lib.mkEnableOption "enable cronjob";
|
||||
port = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = port;
|
||||
};
|
||||
name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = name;
|
||||
};
|
||||
host = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "${subdomain}.${config.my.domain}";
|
||||
@@ -20,4 +24,4 @@ let
|
||||
default = "http://${config.my.localhost}:${toString port}";
|
||||
};
|
||||
};
|
||||
in { inherit mkServerOptions; }
|
||||
in { inherit mkOptions; }
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
{ lib, config, proxyReverse, ... }:
|
||||
let port = 8082;
|
||||
let
|
||||
port = 8082;
|
||||
services = import ./homepage/services.nix { inherit config lib; };
|
||||
in {
|
||||
options.my.servers.homepage.enable = lib.mkEnableOption "enable";
|
||||
config = lib.mkIf config.my.servers.homepage.enable {
|
||||
@@ -32,16 +34,10 @@ in {
|
||||
}
|
||||
];
|
||||
services = [{
|
||||
"Multimedia" = [{
|
||||
Audiobookshelf = lib.mkIf config.my.servers.audiobookshelf.enable {
|
||||
href = config.my.servers.audiobookshelf.url;
|
||||
widget = {
|
||||
type = "audiobookshelf";
|
||||
url = config.my.servers.audiobookshelf.local;
|
||||
key = "{{HOMEPAGE_VAR_AUDIOBOOKSHELF}}";
|
||||
};
|
||||
};
|
||||
}];
|
||||
"Multimedia" = [
|
||||
{ inherit (services) Audiobookshelf; }
|
||||
{ inherit (services) Jellyfin; }
|
||||
];
|
||||
}];
|
||||
};
|
||||
nginx = {
|
||||
|
||||
25
modules/servers/homepage/services.nix
Normal file
25
modules/servers/homepage/services.nix
Normal file
@@ -0,0 +1,25 @@
|
||||
{ config, lib, ... }: {
|
||||
Audiobookshelf = lib.mkIf config.my.servers.audiobookshelf.enable {
|
||||
icon = "${config.my.servers.audiobookshelf.name}.png";
|
||||
href = config.my.servers.audiobookshelf.url;
|
||||
widget = {
|
||||
type = config.my.servers.audiobookshelf.name;
|
||||
url = config.my.servers.audiobookshelf.local;
|
||||
key = "{{HOMEPAGE_VAR_AUDIOBOOKSHELF}}";
|
||||
};
|
||||
};
|
||||
Jellyfin = lib.mkIf config.my.servers.jellyfin.enable {
|
||||
icon = "${config.my.servers.jellyfin.name}.png";
|
||||
href = config.my.servers.jellyfin.url;
|
||||
widget = {
|
||||
type = config.my.servers.jellyfin.name;
|
||||
url = config.my.servers.jellyfin.local;
|
||||
key = "{{HOMEPAGE_VAR_JELLYFIN}}";
|
||||
enableBlocks = true;
|
||||
enableNowPlaying = true;
|
||||
enableUser = true;
|
||||
showEpisodeNumber = true;
|
||||
expandOneStreamToTwoRows = false;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,16 +1,14 @@
|
||||
{ lib, config, pkgs, serviceBase, ... }:
|
||||
let
|
||||
inherit (config.my) localhost;
|
||||
port = 8096;
|
||||
{ lib, config, pkgs, setup, ... }:
|
||||
let cfg = config.my.servers.jellyfin;
|
||||
in {
|
||||
options.my.servers.jellyfin = {
|
||||
enable = lib.mkEnableOption "enable";
|
||||
enableCron = lib.mkEnableOption "enable";
|
||||
};
|
||||
options.my.servers.jellyfin = setup.mkOptions "jellyfin" "flix" 8096;
|
||||
config = lib.mkIf config.my.servers.jellyfin.enable {
|
||||
environment.systemPackages = [ pkgs.jellyfin-ffmpeg ];
|
||||
services = {
|
||||
jellyfin = serviceBase // { };
|
||||
jellyfin = {
|
||||
enable = true;
|
||||
group = "piracy";
|
||||
};
|
||||
nginx = {
|
||||
enable = true;
|
||||
appendHttpConfig = ''
|
||||
@@ -20,7 +18,7 @@ in {
|
||||
map $request_uri $h264Level { ~(h264-level=)(.+?)& $2; }
|
||||
map $request_uri $h264Profile { ~(h264-profile=)(.+?)& $2; }
|
||||
'';
|
||||
virtualHosts."flix.${config.my.domain}" = {
|
||||
virtualHosts."${cfg.host}" = {
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
http2 = true;
|
||||
@@ -28,7 +26,7 @@ in {
|
||||
# use a variable to store the upstream proxy
|
||||
# in this example we are using a hostname which is resolved via DNS
|
||||
# (if you aren't using DNS remove the resolver line and change the variable to point to an IP address
|
||||
resolver ${localhost} valid=30;
|
||||
resolver ${config.my.localhost} valid=30;
|
||||
|
||||
location = / {
|
||||
return 302 http://$host/web/;
|
||||
@@ -37,7 +35,7 @@ in {
|
||||
|
||||
location = /web/ {
|
||||
# Proxy main Jellyfin traffic
|
||||
proxy_pass http://${localhost}:${toString port}/web/index.html;
|
||||
proxy_pass ${cfg.local}/web/index.html;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
@@ -48,11 +46,11 @@ in {
|
||||
'';
|
||||
locations = {
|
||||
"/" = {
|
||||
proxyPass = "http://${localhost}:${toString port}";
|
||||
proxyPass = cfg.local;
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
"/socket" = {
|
||||
proxyPass = "http://${localhost}:${toString port}";
|
||||
proxyPass = cfg.local;
|
||||
extraConfig = ''
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
@@ -60,7 +58,7 @@ in {
|
||||
'';
|
||||
};
|
||||
"~ /Items/(.*)/Images" = {
|
||||
proxyPass = "http://${localhost}:${toString port}";
|
||||
proxyPass = cfg.local;
|
||||
extraConfig = ''
|
||||
proxy_cache jellyfin;
|
||||
proxy_cache_revalidate on;
|
||||
@@ -68,7 +66,7 @@ in {
|
||||
'';
|
||||
};
|
||||
"~* ^/Videos/(.*)/(?!live)" = {
|
||||
proxyPass = "http://${localhost}:${toString port}";
|
||||
proxyPass = cfg.local;
|
||||
extraConfig = ''
|
||||
# Set size of a slice (this amount will be always requested from the backend by nginx)
|
||||
# Higher value means more latency, lower more overhead
|
||||
@@ -101,31 +99,27 @@ in {
|
||||
};
|
||||
};
|
||||
systemd = lib.mkIf config.my.servers.jellyfin.enableCron {
|
||||
services = {
|
||||
sub-sync = let
|
||||
sub-sync = pkgs.writeScriptBin "nextcloud-cronjob"
|
||||
(builtins.readFile ../../scripts/sub-sync.sh);
|
||||
in {
|
||||
restartIfChanged = true;
|
||||
description = "syncronizes subtitles downloaded & modified today";
|
||||
wantedBy = [ "default.target" ];
|
||||
path = [ pkgs.nix sub-sync ];
|
||||
serviceConfig = {
|
||||
Restart = "on-failure";
|
||||
RestartSec = 30;
|
||||
ExecStart = "${sub-sync}/bin/sub-sync all";
|
||||
Type = "forking";
|
||||
User = "root";
|
||||
};
|
||||
services.sub-sync = let
|
||||
sub-sync = pkgs.writeScriptBin "nextcloud-cronjob"
|
||||
(builtins.readFile ../../scripts/sub-sync.sh);
|
||||
in {
|
||||
restartIfChanged = true;
|
||||
description = "syncronizes subtitles downloaded & modified today";
|
||||
wantedBy = [ "default.target" ];
|
||||
path = [ pkgs.nix sub-sync ];
|
||||
serviceConfig = {
|
||||
Restart = "on-failure";
|
||||
RestartSec = 30;
|
||||
ExecStart = "${sub-sync}/bin/sub-sync all";
|
||||
Type = "forking";
|
||||
User = "root";
|
||||
};
|
||||
};
|
||||
timers = {
|
||||
sub-sync = {
|
||||
enable = true;
|
||||
description = "syncronizes subtitles downloaded & modified today";
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = { OnCalendar = "20:00"; };
|
||||
};
|
||||
timers.sub-sync = {
|
||||
enable = true;
|
||||
description = "syncronizes subtitles downloaded & modified today";
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = { OnCalendar = "20:00"; };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user