webapps: introduce module with multiple configurations including dashboard

This commit is contained in:
Felix Buehler 2022-01-23 23:35:00 +01:00
parent 9ea187f809
commit cb7bd7a6eb
9 changed files with 288 additions and 31 deletions

View file

@ -1,30 +0,0 @@
{ config, lib, pkgs, ... }:
{
services = {
# movie management
radarr = {
enable = true;
openFirewall = true;
};
# series management
sonarr = {
enable = true;
openFirewall = true;
};
# subtitle management
bazarr = {
enable = true;
openFirewall = true;
};
# indexer management
prowlarr = {
enable = true;
openFirewall = true;
};
# media player
jellyfin = {
enable = true;
openFirewall = true;
};
};
}

21
extra/webapps/bazarr.nix Normal file
View file

@ -0,0 +1,21 @@
{ config, pkgs, ... }:
{
services.bazarr = {
enable = true;
openFirewall = true;
};
systemd.services.bazarr = {
after = [ "network-online.target" ];
#unitConfig.RequiresMountsFor = [ "/storage" ];
};
webapps.apps.bazarr = {
dashboard = {
name = "Bazarr";
category = "manag";
icon = "closed-captioning";
link = "http://192.168.178.60:6767";
};
};
}

57
extra/webapps/homer.nix Normal file
View file

@ -0,0 +1,57 @@
{ config, lib, pkgs, ... }:
let
homer = pkgs.stdenv.mkDerivation rec {
pname = "homer";
version = "21.09.2";
src = pkgs.fetchurl {
urls = [
"https://github.com/bastienwirtz/${pname}/releases/download/v${version}/${pname}.zip"
];
sha256 = "sha256-NHvH3IW05O1YvPp0KOUU0ajZsuh7BMgqUTJvMwbc+qY=";
};
nativeBuildInputs = [ pkgs.unzip ];
dontInstall = true;
sourceRoot = ".";
unpackCmd = "${pkgs.unzip}/bin/unzip -d $out $curSrc";
};
homeConfig = {
title = "Dashboard";
header = false;
footer = false;
connectivityCheck = true;
colums = "auto";
services = config.lib.webapps.homerServices;
};
in
{
networking.firewall.allowedTCPPorts = [
80
443
];
services.nginx = {
enable = true;
#virtualHosts."dashboard.rocks" = {
virtualHosts."_" = {
default = true;
locations = {
"/" = {
root = homer;
};
"=/assets/config.yml" = {
alias = pkgs.writeText "homerConfig.yml" (builtins.toJSON homeConfig);
};
};
};
};
webapps = {
dashboardCategories = [
{ name = "Applications"; tag = "app"; }
{ name = "Media-Management"; tag = "manag"; }
{ name = "Infrastructure"; tag = "infra"; }
];
};
}

View file

@ -0,0 +1,21 @@
{ config, pkgs, ... }:
{
services.jellyfin = {
enable = true;
openFirewall = true;
};
systemd.services.jellyfin = {
after = [ "network-online.target" ];
#unitConfig.RequiresMountsFor = [ "/storage" ];
};
webapps.apps.jellyfin = {
dashboard = {
name = "Jellyfin";
category = "app";
icon = "film";
link = "http://192.168.178.60:8096";
};
};
}

View file

@ -0,0 +1,31 @@
{ config, pkgs, ... }:
{
services.prowlarr = {
enable = true;
openFirewall = true;
};
systemd.services.prowlarr = {
after = [ "network-online.target" ];
#unitConfig.RequiresMountsFor = [ "/storage" ];
};
webapps.apps.prowlarr = {
dashboard = {
name = "Prowlarr";
category = "manag";
icon = "sync-alt";
link = "http://192.168.178.60:9696";
};
};
# ugly fix for service not having a homedirectory
users.users.prowlarr = {
isSystemUser = true;
home = "/var/lib/prowlarr";
group = "prowlarr";
uid = 61654;
};
users.groups.prowlarr = {
gid = 61654;
};
}

21
extra/webapps/radarr.nix Normal file
View file

@ -0,0 +1,21 @@
{ config, pkgs, ... }:
{
services.radarr = {
enable = true;
openFirewall = true;
};
systemd.services.radarr = {
after = [ "network-online.target" ];
#unitConfig.RequiresMountsFor = [ "/storage" ];
};
webapps.apps.radarr = {
dashboard = {
name = "Radarr";
category = "manag";
icon = "film";
link = "http://192.168.178.60:7878";
};
};
}

21
extra/webapps/sonarr.nix Normal file
View file

@ -0,0 +1,21 @@
{ config, pkgs, ... }:
{
services.sonarr = {
enable = true;
openFirewall = true;
};
systemd.services.sonarr = {
after = [ "network-online.target" ];
#unitConfig.RequiresMountsFor = [ "/storage" ];
};
webapps.apps.sonarr = {
dashboard = {
name = "Sonarr";
category = "manag";
icon = "tv";
link = "http://192.168.178.60:8989";
};
};
}

109
modules/webapps/default.nix Normal file
View file

@ -0,0 +1,109 @@
{ config, lib, pkgs, ... }:
{
options.webapps = {
dashboardCategories = lib.mkOption {
type = lib.types.listOf (lib.types.submodule {
options = {
name = lib.mkOption {
type = lib.types.str;
description = ''
Category name.
'';
example = "Applications";
};
tag = lib.mkOption {
type = lib.types.str;
description = ''
Category tag.
'';
example = "app";
};
};
});
description = ''
App categories to display on the dashboard.
'';
example = [
{
name = "Application";
tag = "app";
}
];
default = [ ];
};
apps = lib.mkOption {
type = lib.types.attrsOf
(lib.types.submodule {
options = {
dashboard.link = lib.mkOption {
type = lib.types.nullOr lib.types.str;
description = ''
Link to webapp
'';
example = "http://192.168.1.10:1234";
default = null;
};
dashboard.name = lib.mkOption {
type = lib.types.nullOr lib.types.str;
description = ''
Application name.
'';
example = "App";
default = null;
};
dashboard.category = lib.mkOption {
type = lib.types.nullOr lib.types.str;
description = ''
App category tag.
'';
example = "app";
default = null;
};
dashboard.icon = lib.mkOption {
type = lib.types.nullOr lib.types.str;
description = ''
Font Awesome application icon.
'';
example = "rss";
default = null;
};
};
});
description = ''
Defines a web application.
'';
default = { };
};
};
config =
let
cfg = config.webapps;
in {
lib.webapps.homerServices =
let
apps = builtins.filter (a: a.dashboard.name != null) (lib.attrValues cfg.apps);
in
lib.forEach cfg.dashboardCategories (cat:
let
catApps = lib.sort (a: b: a.dashboard.name < b.dashboard.name) (
builtins.filter
(a:
a.dashboard.category != null && a.dashboard.category == cat.tag ||
a.dashboard.category == null && cat.tag == "misc")
apps);
in
{
name = cat.name;
items = lib.forEach catApps (a: {
name = a.dashboard.name;
icon = lib.optionalString (a.dashboard.icon != null) "fas fa-${a.dashboard.icon}";
url = a.dashboard.link;
target = "_blank";
});
}
);
};
}

View file

@ -13,10 +13,16 @@
./extra/development.nix
./extra/docker.nix
./extra/dyndns.nix
./extra/media-server.nix
./extra/networkdecrypt.nix
./extra/nix.nix
./extra/ssh.nix
./modules/webapps
./extra/webapps/bazarr.nix
./extra/webapps/homer.nix
./extra/webapps/jellyfin.nix
./extra/webapps/prowlarr.nix
./extra/webapps/radarr.nix
./extra/webapps/sonarr.nix
./hardware/raspberrypi4.nix
];
networking.hostName = "serverle";