Update modules/server/containers/apps/homepage.nix

This commit is contained in:
2026-06-08 12:02:27 +02:00
parent a899fe4c6f
commit 59dd62b9c9

View File

@@ -1,293 +1,350 @@
{ config, containerCfg, pkgs, lib, builder, name,... }: { config, containerCfg, pkgs, lib, builder, name, ... }:
let let
version = "latest"; version = "latest";
serverCfg = config.syscfg.server; serverCfg = config.syscfg.server;
mediaCfg = config.syscfg.media; mediaCfg = config.syscfg.media;
backgroundImage = if mediaCfg.banner.png != null then mediaCfg.banner.png else mediaCfg.bg; homepageExtra = containerCfg.extra or {};
backgroundFileName = builtins.baseNameOf (toString backgroundImage); backgroundImage = if mediaCfg.banner.png != null then mediaCfg.banner.png else mediaCfg.bg;
backgroundMount = "/app/public/media/${backgroundFileName}"; backgroundFileName = builtins.baseNameOf (toString backgroundImage);
backgroundMount = "/app/public/media/${backgroundFileName}";
latitude =
if homepageExtra ? latitude then homepageExtra.latitude
else if homepageExtra ? lat then homepageExtra.lat
else 47.3769;
longitude =
if homepageExtra ? longitude then homepageExtra.longitude
else if homepageExtra ? lon then homepageExtra.lon
else 8.5417;
extraBookmarks = homepageExtra.bookmarks or [];
extraServices = homepageExtra.services or [];
settings = pkgs.writers.writeYAML "settings.yaml" { settings = pkgs.writers.writeYAML "settings.yaml" {
title = "Home"; title = "Home";
description = ""; description = "";
startUrl = "https://${containerCfg.subdomain}.${serverCfg.domain}"; startUrl = "https://${containerCfg.subdomain}.${serverCfg.domain}";
background = { background = {
image = "/media/${backgroundFileName}"; image = "/media/${backgroundFileName}";
blur = "xs"; # "", sm, md, xl,... brightness = 50;
# saturate = ""; };
brightness = 50; cardBlur = "md";
# opacity = 40; favicon = config.syscfg.media.logo.ico;
}; theme = "dark";
cardBlur = "md"; color = "slate";
# favicon = ""; fullWidth = true;
theme = "dark"; useEqualHeights = true;
color = "slate"; pwa = { };
fullWidth = true; layout = {
useEqualHeights = true; Admin = {
pwa = { style = "row";
columns = 4;
};
};
providers = {
finnhub = "{{HOMEPAGE_VAR_FINNHUB}}";
};
headerStyle = "clean";
hideVersion = true;
disableUpdateCheck = true;
showStats = false;
statusStyle = "dot";
hideErrors = true;
};
}; widgets = pkgs.writers.writeYAML "widgets.yaml" [
layout = { { openmeteo = {
Admin = { latitude = toString latitude;
style = "row"; longitude = toString longitude;
columns = 4; timezone = config.time.timeZone;
units = "metric";
cache = "15";
};
}
{ search = {
provider = "custom";
focus = true;
showSearchSuggestions = true;
target = "_blank";
} // (lib.optionalAttrs (serverCfg.containers ? searxng) {
url = "https://${serverCfg.containers.searxng.subdomain}.${serverCfg.domain}/search?q=";
suggestionUrl = "https://${serverCfg.containers.searxng.subdomain}.${serverCfg.domain}/autocompleter?q=";
});
}
{ stocks = {
provider = "finnhub";
color = true;
cache = 15;
watchlist = homepageExtra.stocks or [];
};
}
];
bookmarks = pkgs.writers.writeYAML "bookmarks.yaml" (extraBookmarks);
services = pkgs.writers.writeYAML "services.yaml" ([
{ Media = lib.flatten [
(lib.optional (serverCfg.containers ? jellyfin) {
Jellyfin = {
icon = "jellyfin.png";
href = "https://${serverCfg.containers.jellyfin.subdomain}.${serverCfg.domain}";
widget = {
type = "jellyfin";
url = "http://jellyfin-server:8096";
key = "{{HOMEPAGE_VAR_JELLYFIN_API}}";
}; };
}; };
providers = { })
finnhub = "{{HOMEPAGE_VAR_FINNHUB}}"; (lib.optional (serverCfg.containers ? invidious) {
}; Invidious = {
headerStyle = "clean"; icon = "invidious.png";
hideVersion = true; href = "https://${serverCfg.containers.invidious.subdomain}.${serverCfg.domain}";
disableUpdateCheck = true; };
showStats = false; })
statusStyle = "dot"; (lib.optional (serverCfg.containers ? calibre) {
hideErrors = true; Calibre = {
}; icon = "calibre.png";
widgets = pkgs.writers.writeYAML "widgets.yaml" [ href = "https://${serverCfg.containers.calibre.subdomain}.${serverCfg.domain}";
{openmeteo = { };
latitude = "47.3769"; })
longitude = "8.5417"; (lib.optional (serverCfg.containers ? freshrss) {
timezone = "Europe/Zurich"; FreshRSS = {
units = "metric"; icon = "freshrss.png";
cache = "15"; href = "https://${serverCfg.containers.freshrss.subdomain}.${serverCfg.domain}";
};} };
{search = { })
provider = "custom"; (lib.optional (serverCfg.containers ? miniflux) {
focus = true; Miniflux = {
showSearchSuggestions = true; icon = "miniflux.png";
target = "_blank"; href = "https://${serverCfg.containers.miniflux.subdomain}.${serverCfg.domain}";
} // (lib.optionalAttrs (serverCfg.containers?searxng) { widget = {
url = "https://${serverCfg.containers.searxng.subdomain}.${serverCfg.domain}/search?q="; type = "miniflux";
suggestionUrl = "https://${serverCfg.containers.searxng.subdomain}.${serverCfg.domain}/autocompleter?q="; url = "http://miniflux-server";
}); key = "{{HOMEPAGE_VAR_MINIFLUX_API}}";
} };
{stocks = { };
provider = "finnhub"; })
color = true; (lib.optional (serverCfg.containers ? suwayomi) {
cache = 15; Suwayomi = {
watchlist = containerCfg.extra.stocks or []; icon = "suwayomi.png";
href = "https://${serverCfg.containers.suwayomi.subdomain}.${serverCfg.domain}";
};} };
]; })
];
bookmarks = pkgs.writers.writeYAML "bookmarks.yaml" [ }
{ Cloud = lib.flatten [
]; (lib.optional (serverCfg.containers ? nextcloud) {
services = pkgs.writers.writeYAML "services.yaml" [ Nextcloud = {
{Media = lib.flatten [ icon = "nextcloud.png";
(lib.optional (serverCfg.containers?jellyfin) { href = "https://${serverCfg.containers.nextcloud.subdomain}.${serverCfg.domain}";
Jellyfin={ widget = {
icon = "jellyfin.png"; type = "nextcloud";
href = "https://${serverCfg.containers.jellyfin.subdomain}.${serverCfg.domain}"; url = "http://nextcloud-server:80";
widget = { key = "{{HOMEPAGE_VAR_NEXTCLOUD_API}}";
type="jellyfin"; };
url = "http://jellyfin-server:8096"; };
key = "{{HOMEPAGE_VAR_JELLYFIN_API}}"; })
}; (lib.optional (serverCfg.containers ? ethercalc) {
}; Ethercalc = {
}) icon = "ethercalc.png";
(lib.optional (serverCfg.containers?invidious) { href = "https://${serverCfg.containers.ethercalc.subdomain}.${serverCfg.domain}";
Invidious={ };
icon = "invidious.png"; })
href = "https://${serverCfg.containers.invidious.subdomain}.${serverCfg.domain}"; (lib.optional (serverCfg.containers ? etherpad) {
}; Etherpad = {
}) icon = "etherpad.png";
(lib.optional (serverCfg.containers?miniflux) { href = "https://${serverCfg.containers.etherpad.subdomain}.${serverCfg.domain}";
Miniflux={ };
icon = "miniflux.png"; })
href = "https://${serverCfg.containers.miniflux.subdomain}.${serverCfg.domain}"; (lib.optional (serverCfg.containers ? collabora && false) {
widget = { Collabora = {
type="miniflux"; icon = "microsoft-office.png";
url = "http://miniflux-server"; href = "https://${serverCfg.containers.collabora.subdomain}.${serverCfg.domain}";
key = "{{HOMEPAGE_VAR_MINIFLUX_API}}"; };
}; })
}; (lib.optional (serverCfg.containers ? immich) {
}) Immich = {
];} icon = "immich.png";
{Cloud = lib.flatten [ href = "https://${serverCfg.containers.immich.subdomain}.${serverCfg.domain}";
(lib.optional (serverCfg.containers?nextcloud) { widget = {
Nextcloud={ type = "immich";
icon = "nextcloud.png"; url = "http://immich-server:80";
href = "https://${serverCfg.containers.nextcloud.subdomain}.${serverCfg.domain}"; key = "{{HOMEPAGE_VAR_IMMICH_API}}";
widget = { version = "2";
type="nextcloud"; };
url = "http://nextcloud-server:80"; };
key = "{{HOMEPAGE_VAR_NEXTCLOUD_API}}"; })
}; ];
}; }
}) { Home = lib.flatten [
(lib.optional (serverCfg.containers?ethercalc) { (lib.optional (serverCfg.containers ? homeassistant) {
Ethercalc={ "Home Assistant" = {
icon = "ethercalc.png"; icon = "home-assistant.png";
href = "https://${serverCfg.containers.ethercalc.subdomain}.${serverCfg.domain}"; href = "https://${serverCfg.containers.homeassistant.subdomain}.${serverCfg.domain}";
}; };
}) })
(lib.optional (serverCfg.containers?etherpad) { (lib.optional (serverCfg.containers ? openhab) {
Etherpad={ openHAB = {
icon = "etherpad.png"; icon = "openhab.png";
href = "https://${serverCfg.containers.etherpad.subdomain}.${serverCfg.domain}"; href = "https://${serverCfg.containers.openhab.subdomain}.${serverCfg.domain}";
}; };
}) })
(lib.optional (serverCfg.containers?immich) { (lib.optional (serverCfg.containers ? frigate) {
immich={ Frigate = {
icon = "immich.png"; icon = "frigate.png";
href = "https://${serverCfg.containers.immich.subdomain}.${serverCfg.domain}"; href = "https://${serverCfg.containers.frigate.subdomain}.${serverCfg.domain}";
widget = { };
type="immich"; })
url = "http://immich-server:80"; ];
key = "{{HOMEPAGE_VAR_IMMICH_API}}"; }
version = "2"; { Dev = lib.flatten [
}; (lib.optional (serverCfg.containers ? gitea) {
}; Gitea = {
}) icon = "gitea.png";
];} href = "https://${serverCfg.containers.gitea.subdomain}.${serverCfg.domain}";
{Dev = lib.flatten [ };
(lib.optional (serverCfg.containers?gitea) { })
Gitea={ (lib.optional (serverCfg.containers ? trmnl) {
icon = "gitea.png"; TRMNL = {
href = "https://${serverCfg.containers.gitea.subdomain}.${serverCfg.domain}"; icon = "terminal.png";
# widget = { href = "https://${serverCfg.containers.trmnl.subdomain}.${serverCfg.domain}";
# type="gitea"; };
# url = "http://gitea-server:8080"; })
# key = "{{HOMEPAGE_VAR_GITEA_API}}"; ];
# }; }
}; { Admin = lib.flatten [
}) (lib.optional (serverCfg.containers ? traefik) {
];} Traefik = {
{Admin = #lib.flatten [ icon = "traefik.png";
#({permissions.groups = ["admin"];}) href = "https://${serverCfg.containers.traefik.subdomain}.${serverCfg.domain}";
#({services = widget = {
lib.flatten [ type = "traefik";
(lib.optional (serverCfg.containers?traefik) { url = "http://traefik-server:8080";
Traefik={ };
icon = "traefik.png"; };
href = "https://${serverCfg.containers.traefik.subdomain}.${serverCfg.domain}"; })
widget = { (lib.optional (serverCfg.containers ? authentik) {
type = "traefik"; Authentik = {
url = "http://traefik-server:8080"; icon = "authentik.png";
}; href = "https://${serverCfg.containers.authentik.subdomain}.${serverCfg.domain}";
}; widget = {
}) type = "authentik";
(lib.optional (serverCfg.containers?authentik) { url = "http://authentik-server:9000";
Authentik={ key = "{{HOMEPAGE_VAR_AUTHENTIK_API}}";
icon = "authentik.png"; version = "2";
href = "https://${serverCfg.containers.authentik.subdomain}.${serverCfg.domain}"; };
widget = { };
type = "authentik"; })
url = "http://authentik-server:9000"; (lib.optional (serverCfg.containers ? umami) {
key = "{{HOMEPAGE_VAR_AUTHENTIK_API}}"; Umami = {
version = "2"; icon = "umami.png";
}; href = "https://${serverCfg.containers.umami.subdomain}.${serverCfg.domain}";
}; };
}) })
(lib.optional (serverCfg.containers?umami) { (lib.optional (serverCfg.containers ? influx) {
Umami={ Influx = {
icon = "umami.png"; icon = "grafana.png";
href = "https://${serverCfg.containers.umami.subdomain}.${serverCfg.domain}"; href = "https://${serverCfg.containers.influx.subdomain}.${serverCfg.domain}";
}; };
}) })
(lib.optional (serverCfg.containers?influx) { (lib.optional (serverCfg.containers ? handbrake) {
Influx={ Handbrake = {
icon = "grafana.png"; icon = "handbrake.png";
href = "https://${serverCfg.containers.influx.subdomain}.${serverCfg.domain}"; href = "https://${serverCfg.containers.handbrake.subdomain}.${serverCfg.domain}";
}; };
}) })
(lib.optional (serverCfg.containers?handbrake) { (lib.optional (serverCfg.containers ? transmission) {
Handbrake={ Transmission = {
icon = "handbrake.png"; icon = "transmission.png";
href = "https://${serverCfg.containers.handbrake.subdomain}.${serverCfg.domain}"; href = "https://${serverCfg.containers.transmission.subdomain}.${serverCfg.domain}/transmission";
}; widget = {
}) type = "transmission";
(lib.optional (serverCfg.containers?transmission) { url = "http://transmission-server:9091";
Transmission={ rpcUrl = "/transmission/";
icon = "transmission.png"; };
href = "https://${serverCfg.containers.transmission.subdomain}.${serverCfg.domain}/transmission"; };
widget = { })
type = "transmission"; (lib.optional (serverCfg.containers ? selfmark) {
url = "http://transmission-server:9091"; Selfmark = {
rpcUrl = "/transmission/"; icon = "link.png";
}; href = "https://${serverCfg.containers.selfmark.subdomain}.${serverCfg.domain}";
}; };
}) })
(lib.optional (serverCfg.containers?servarr) ( (lib.optional (serverCfg.containers ? servarr) (
let let
modules = serverCfg.containers.servarr.extra.modules or ["prowlarr" "sonarr" "radarr" "flaresolverr" ]; modules = serverCfg.containers.servarr.extra.modules or [ "prowlarr" "sonarr" "radarr" "flaresolverr" ];
in in
(lib.optional (builtins.elem "sonarr" modules) { (lib.optional (builtins.elem "sonarr" modules) {
Sonarr={ Sonarr = {
icon = "sonarr.png"; icon = "sonarr.png";
href = "https://${serverCfg.containers.servarr.subdomain}.${serverCfg.domain}/sonarr"; href = "https://${serverCfg.containers.servarr.subdomain}.${serverCfg.domain}/sonarr";
widget = { widget = {
type = "sonarr"; type = "sonarr";
url = "http://servarr-sonarr:8989"; url = "http://servarr-sonarr:8989";
key = "{{HOMEPAGE_VAR_SONARR_API}}"; key = "{{HOMEPAGE_VAR_SONARR_API}}";
};
};
}) ++ (lib.optional (builtins.elem "radarr" modules) {
Radarr={
icon = "radarr.png";
href = "https://${serverCfg.containers.servarr.subdomain}.${serverCfg.domain}/radarr";
widget = {
type = "radarr";
url = "http://servarr-radarr:8989";
key = "{{HOMEPAGE_VAR_RADARR_API}}";
};
};
}) ++ (lib.optional (builtins.elem "lidarr" modules) {
Lidarr={
icon = "lidarr.png";
href = "https://${serverCfg.containers.servarr.subdomain}.${serverCfg.domain}/lidarr";
widget = {
type = "lidarr";
url = "http://servarr-lidarr:8989";
key = "{{HOMEPAGE_VAR_LIDARR_API}}";
};
};
}) ++ (lib.optional (builtins.elem "prowlarr" modules) {
Prowlarr={
icon = "prowlarr.png";
href = "https://${serverCfg.containers.servarr.subdomain}.${serverCfg.domain}/prowlarr";
widget = {
type = "prowlarr";
url = "http://servarr-prowlarr:8989";
key = "{{HOMEPAGE_VAR_PROWLARR_API}}";
};
}; };
};
}) })
# Bazarr ++ (lib.optional (builtins.elem "radarr" modules) {
Radarr = {
)) icon = "radarr.png";
];}#)];} href = "https://${serverCfg.containers.servarr.subdomain}.${serverCfg.domain}/radarr";
]; widget = {
type = "radarr";
url = "http://servarr-radarr:8989";
key = "{{HOMEPAGE_VAR_RADARR_API}}";
};
};
})
++ (lib.optional (builtins.elem "lidarr" modules) {
Lidarr = {
icon = "lidarr.png";
href = "https://${serverCfg.containers.servarr.subdomain}.${serverCfg.domain}/lidarr";
widget = {
type = "lidarr";
url = "http://servarr-lidarr:8989";
key = "{{HOMEPAGE_VAR_LIDARR_API}}";
};
};
})
++ (lib.optional (builtins.elem "prowlarr" modules) {
Prowlarr = {
icon = "prowlarr.png";
href = "https://${serverCfg.containers.servarr.subdomain}.${serverCfg.domain}/prowlarr";
widget = {
type = "prowlarr";
url = "http://servarr-prowlarr:8989";
key = "{{HOMEPAGE_VAR_PROWLARR_API}}";
};
};
})
))
];
}
] ++ extraServices);
in { in {
runtime = { runtime = {
containers = { containers = {
server = builder.mkContainer { server = builder.mkContainer {
subdomain = containerCfg.subdomain; subdomain = containerCfg.subdomain;
image = "ghcr.io/gethomepage/homepage:${version}"; image = "ghcr.io/gethomepage/homepage:${version}";
port = 3000; port = 3000;
extraEnv = { extraEnv = {
HOMEPAGE_VAR_TITLE="${serverCfg.domain}"; HOMEPAGE_VAR_TITLE = "${serverCfg.domain}";
HOMEPAGE_ALLOWED_HOSTS = "${containerCfg.subdomain}.${serverCfg.domain},${builder.host}"; HOMEPAGE_ALLOWED_HOSTS = "${containerCfg.subdomain}.${serverCfg.domain},${builder.host}";
}; };
extraLabels = { extraLabels = {
"traefik.http.routers.${containerCfg.subdomain}.service" = "${containerCfg.subdomain}"; "traefik.http.routers.${containerCfg.subdomain}.service" = "${containerCfg.subdomain}";
}; };
overrides = { overrides = {
environmentFiles = [ config.sops.secrets."CUSTOM".path ]; environmentFiles = [ config.sops.secrets."CUSTOM".path ];
volumes = [ volumes = [
"${settings}:/app/config/settings.yaml:ro" "${settings}:/app/config/settings.yaml:ro"
"${services}:/app/config/services.yaml:ro" "${services}:/app/config/services.yaml:ro"
"${widgets}:/app/config/widgets.yaml:ro" "${widgets}:/app/config/widgets.yaml:ro"
"${bookmarks}:/app/config/bookmarks.yaml:ro" "${bookmarks}:/app/config/bookmarks.yaml:ro"
"${backgroundImage}:${backgroundMount}:ro" "${backgroundImage}:${backgroundMount}:ro"
]; ];
}; };
};
}; };
}; };
};
} }