mirror of
https://github.com/Stunkymonkey/nixos.git
synced 2025-07-04 16:59:30 +02:00
service/homer: simplify
This commit is contained in:
parent
efd88fb11b
commit
6d3a814015
2 changed files with 36 additions and 38 deletions
|
@ -105,39 +105,46 @@
|
|||
config =
|
||||
let
|
||||
cfg = config.webapps;
|
||||
appsWithName = builtins.filter (app: app.dashboard.name != null) (lib.attrValues cfg.apps);
|
||||
in
|
||||
{
|
||||
lib.webapps.homerServices =
|
||||
lib.webapps.homerServices = lib.forEach cfg.dashboardCategories (
|
||||
category:
|
||||
let
|
||||
apps = builtins.filter (a: a.dashboard.name != null) (lib.attrValues cfg.apps);
|
||||
catTag = category.tag;
|
||||
catApps = lib.sort (a: b: a.dashboard.name < b.dashboard.name) (
|
||||
builtins.filter (
|
||||
app:
|
||||
let
|
||||
cat = app.dashboard.category;
|
||||
in
|
||||
(cat != null && cat == catTag) || (cat == null && catTag == "misc")
|
||||
) appsWithName
|
||||
);
|
||||
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
|
||||
{
|
||||
inherit (cat) name;
|
||||
items = lib.forEach catApps (a: {
|
||||
inherit (a.dashboard)
|
||||
{
|
||||
inherit (category) name;
|
||||
items = lib.forEach catApps (
|
||||
app:
|
||||
let
|
||||
dash = app.dashboard;
|
||||
in
|
||||
{
|
||||
inherit (dash)
|
||||
method
|
||||
name
|
||||
type
|
||||
url
|
||||
;
|
||||
icon = lib.optionalString (a.dashboard.icon != null) "fas fa-${a.dashboard.icon}";
|
||||
icon = lib.optionalString (dash.icon != null) "fas fa-${dash.icon}";
|
||||
target = "_blank";
|
||||
});
|
||||
}
|
||||
);
|
||||
my.services.blackbox.http_endpoints =
|
||||
lib.mapAttrsToList (_key: value: value.dashboard.url) config.webapps.apps
|
||||
++ [ "https://${config.networking.domain}/" ];
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
my.services.blackbox.http_endpoints = lib.mapAttrsToList (_: app: app.dashboard.url) cfg.apps ++ [
|
||||
"https://${config.networking.domain}/"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -10,10 +10,8 @@ let
|
|||
inherit (config.networking) domain;
|
||||
|
||||
homeConfig = {
|
||||
title = "Dashboard";
|
||||
header = false;
|
||||
footer = false;
|
||||
connectivityCheck = true;
|
||||
columns = "auto";
|
||||
services = config.lib.webapps.homerServices;
|
||||
};
|
||||
|
@ -26,18 +24,11 @@ in
|
|||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
# TODO: 25.05 use stable
|
||||
services.caddy.virtualHosts.${domain} = {
|
||||
extraConfig = ''
|
||||
import common
|
||||
root * ${pkgs.unstable.homer}
|
||||
file_server
|
||||
handle_path /assets/config.yml {
|
||||
root * ${pkgs.writeText "homerConfig.yml" (builtins.toJSON homeConfig)}
|
||||
file_server
|
||||
}
|
||||
'';
|
||||
useACMEHost = domain;
|
||||
services.homer = {
|
||||
enable = true;
|
||||
virtualHost.caddy.enable = true;
|
||||
virtualHost.domain = domain;
|
||||
settings = homeConfig;
|
||||
};
|
||||
|
||||
webapps = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue