Skip to content

Commit

Permalink
feat(nixos): improve media homepage
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
  • Loading branch information
caarlos0 committed Jan 4, 2024
1 parent c3ae757 commit f75aca2
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 54 deletions.
70 changes: 42 additions & 28 deletions machines/media/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,28 @@ in

services.nginx = {
enable = true;
upstreams = {
tautulli.servers."media.local:8181" = { };
};
virtualHosts."media.local" = {
root = (pkgs.callPackage ../../pkgs/homer { });
locations."~ /tautulli/(.*)" = {
proxyPass = "http://tautulli/$1$is_args$args";
priority = 1;
extraConfig = ''
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
'';
};
locations."/" = {
root = (pkgs.callPackage ../../pkgs/homer { });
};
};
};

networking.firewall.allowedTCPPorts = [ 80 443 5055 ];
networking.firewall.allowedTCPPorts = [ 80 443 5055 8090 8091 ];

services.plex = {
enable = true;
Expand Down Expand Up @@ -60,32 +76,6 @@ in
openFirewall = true;
};

systemd.services.qbittorrent = {
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "exec";
User = "carlos";
Group = "wheel";
ExecStart = "${pkgs.qbittorrent-nox}/bin/qbittorrent-nox --webui-port=8090";
Restart = "on-failure";
ProtectSystem = "strict";
};
};

systemd.services.flood = {
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "exec";
User = "carlos";
Group = "wheel";
ExecStart = "${pkgs.flood}/bin/flood --host 0.0.0.0 --port=8091";
Restart = "on-failure";
ProtectSystem = "strict";
};
};

systemd.services.unpackerr = {
description = "Unpackerr";
after = [ "network.target" ];
Expand Down Expand Up @@ -145,7 +135,31 @@ in
};
};

systemd.services.qbittorrent = {
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "exec";
User = "carlos";
Group = "wheel";
ExecStart = "${pkgs.qbittorrent-nox}/bin/qbittorrent-nox --webui-port=8090";
Restart = "on-failure";
ProtectSystem = "strict";
};
};

systemd.services.flood = {
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "exec";
User = "carlos";
Group = "wheel";
ExecStart = "${pkgs.flood}/bin/flood --host 0.0.0.0 --port=8091";
Restart = "on-failure";
ProtectSystem = "strict";
};
};

# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
Expand Down
86 changes: 60 additions & 26 deletions pkgs/homer/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{ stdenv, fetchzip, pkgs, ... }:
# with import <nixpkgs> { };
{ fetchFromGitHub
, fetchYarnDeps
, mkYarnPackage
, pkgs
, ...
}:
let
formatYaml = pkgs.formats.yaml { };
config = formatYaml.generate "config.yml" {
Expand All @@ -11,26 +17,27 @@ let
items = [
{
name = "Plex";
subtitle = "Media Server";
url = "http://media.local:32400/web";
endpoint = "http://media.local:8181";
endpoint = "http://media.local/tautulli";
logo = "https://raw.githubusercontent.com/NX211/homer-icons/master/png/plex.png";
type = "Tautulli";
apikey = "779ac777f02245fda8f23879e0b9eb37";
target = "_blank";
}
{
name = "Overseerr";
subtitle = "Request Media";
logo = "https://raw.githubusercontent.com/NX211/homer-icons/master/png/overseerr.png";
url = "http://media.local:5055";
target = "_blank";
}
];
}
{
name = "Statistics";
items = [
{
name = "Tautulli";
endpoint = "http://media.local:8181";
subtitle = "Plex Statistics";
url = "http://media.local:8181";
logo = "https://raw.githubusercontent.com/NX211/homer-icons/master/png/tautulli.png";
endpoint = "http://media.local/tautulli";
type = "Tautulli";
apikey = "779ac777f02245fda8f23879e0b9eb37";
target = "_blank";
Expand All @@ -41,31 +48,45 @@ let
name = "Download";
items = [
{
name = "Series";
name = "qBittorrent";
subtitle = "Downloads";
logo = "https://raw.githubusercontent.com/NX211/homer-icons/master/png/qbittorrent.png";
url = "http://media.local:8091/";
endpoint = "http://media.local:8090";
target = "_blank";
type = "qBittorrent";
username = "admin";
password = "adminadmin";
}
{
name = "Sonarr";
subtitle = "Series";
logo = "https://raw.githubusercontent.com/NX211/homer-icons/master/png/sonarr.png";
type = "Sonarr";
url = "http://media.local:8989/";
apikey = "71c261a86baf491784a60fa7489620fc";
target = "_blank";
}
{
name = "Movies";
name = "Radarr";
subtitle = "Movies";
logo = "https://raw.githubusercontent.com/NX211/homer-icons/master/png/radarr.png";
type = "Radarr";
url = "http://media.local:7878/";
apikey = "0042dc1c54444388b0ed680187f11b37";
target = "_blank";
}
{
name = "Subtitles";
name = "Bazarr";
subtitle = "Subtitles";
logo = "https://raw.githubusercontent.com/NX211/homer-icons/master/png/bazarr.png";
url = "http://media.local:6767/";
target = "_blank";
}
{
name = "Torrents";
url = "http://media.local:8091/";
target = "_blank";
}
{
name = "Indexer";
name = "Prowlarr";
subtitle = "Indexers";
logo = "https://raw.githubusercontent.com/NX211/homer-icons/master/png/prowlarr.png";
url = "http://media.local:9696/";
type = "Prowlarr";
apikey = "171a6baff00a4b918e722a7de9befaa1";
Expand All @@ -76,18 +97,31 @@ let
];
};
in
stdenv.mkDerivation rec {
mkYarnPackage rec {
name = "homer";
version = "23.10.1";
src = fetchzip {
url = "https://github.com/bastienwirtz/homer/releases/download/v${version}/homer.zip";
hash = "sha256-KUEqrjO9LAoigZsQGLy5JrtsXx+HDXaz4Y4Vpba0uNw=";
stripRoot = false;
version = "fork";
src = fetchFromGitHub {
owner = "caarlos0";
repo = "homer";
rev = "main";
hash = "sha256-xNziRpNVCM13IckyETbD4LQ4YWWlvXUz4OLooayFmVI=";
};

offlineCache = fetchYarnDeps {
yarnLock = "${src}/yarn.lock";
hash = "sha256-6OAK9zTF/Yev4f/yg3GZfkFMflBzspt3vDnVpo71DPw=";
};

installPhase = ''
mkdir -vp $out
cp -r . $out
distPhase = "true";

buildPhase = ''
export HOME=$(mktemp -d)
yarn --offline build
'';

fixupPhase = ''
cp -rf $out/libexec/homer/deps/homer/dist/* $out
rm -rf $out/bin $out/libexec
cp -r ${config} $out/assets/config.yml
'';
}

0 comments on commit f75aca2

Please sign in to comment.