diff --git a/modules/server/containers/apps/favicon.nix b/modules/server/containers/apps/favicon.nix index 54af9a6..e57ff03 100644 --- a/modules/server/containers/apps/favicon.nix +++ b/modules/server/containers/apps/favicon.nix @@ -2,6 +2,7 @@ let serverCfg = config.syscfg.server; mediaCfg = config.syscfg.media; + palette = serverCfg.colorScheme.palette or { }; port = 8080; assetSize = 64; cacheControl = containerCfg.extra.cacheControl or "public, max-age=86400"; @@ -9,10 +10,32 @@ let logoSvgFileName = builtins.baseNameOf (toString mediaCfg.logo.svg); logoSvgMount = "/assets/${logoSvgFileName}"; borderRadius = toString (containerCfg.extra.borderRadius or 32); + resolveColor = value: + if value == null then null + else if !builtins.isString value then + throw "favicon color values must be strings" + else if lib.hasPrefix "#" value then + value + else + lib.attrByPath [ value ] (throw "Unknown favicon color reference `${value}`") palette; + normalizeProfile = profile: + let + bg = + if profile ? bg then resolveColor profile.bg + else if profile ? background then resolveColor profile.background + else null; + fg = + if profile ? fg then resolveColor profile.fg + else if profile ? foreground then resolveColor profile.foreground + else null; + in + (lib.filterAttrs (name: _: !(builtins.elem name [ "bg" "background" "fg" "foreground" ])) profile) + // lib.optionalAttrs (bg != null) { bg = bg; } + // lib.optionalAttrs (fg != null) { fg = fg; }; hostMappings = lib.mapAttrs' (mapping: profile: lib.nameValuePair (if lib.hasInfix "." mapping then mapping else "${mapping}.${serverCfg.domain}") - profile + (normalizeProfile profile) ) (containerCfg.extra.mappings or {}); traefikAssetPathRegexp = "^/(.*/)?" @@ -26,7 +49,9 @@ let inherit cacheControl; borderRadius = borderRadius; mappings = hostMappings; - default = containerCfg.extra.default or null; + default = + if containerCfg.extra ? default then normalizeProfile containerCfg.extra.default + else null; }); pythonEnv = pkgs.python3.withPackages (ps: with ps; [ cairosvg @@ -104,8 +129,8 @@ let return f"{text}px" def _render_svg(profile): - bg = _color(profile.get("background"), "#111827") - fg = _color(profile.get("foreground"), "#f8fafc") + bg = _color(profile.get("bg") or profile.get("background"), "#111827") + fg = _color(profile.get("fg") or profile.get("foreground"), "#f8fafc") border_radius = _border_radius() logo_data_uri = _tinted_logo_data_uri(fg) diff --git a/systems/sandbox/cfg.nix b/systems/sandbox/cfg.nix index 2573539..fdbaca8 100644 --- a/systems/sandbox/cfg.nix +++ b/systems/sandbox/cfg.nix @@ -38,11 +38,11 @@ homepage.subdomain = "home"; homepage.extra.stocks = [ "GLD" "VOO" "QUIK" "AMD" "DPRO" "KTOS" "NNE" "NVO" ]; # ===== CLOUD ===== - # nextcloud.subdomain = "cloud"; - # collabora.subdomain = "office"; - # etherpad.subdomain = "pad"; + nextcloud.subdomain = "cloud"; + collabora.subdomain = "office"; + etherpad.subdomain = "pad"; # ethercalc.subdomain = "calc"; - # immich.subdomain = "pic"; + immich.subdomain = "pic"; # ===== FLIX ===== # invidious.subdomain = "yt"; # jellyfin.subdomain = "flix"; @@ -51,39 +51,42 @@ # transmission = { subdomain = "arr"; subpath = "transmission"; }; # handbrake = { subdomain = "arr"; subpath = "hb"; }; # ===== DEV ===== - # gitea.subdomain = "git"; + gitea.subdomain = "git"; # ===== HOME ===== # openhab.subdomain = "hab"; # trmnl = { subdomain = "hass"; subpath = "trmnl"; }; influx.subdomain = "metrum"; - # freshrss.subdomain = "rss"; - # suwayomi.subdomain = "manga"; - # calibre.subdomain = "books"; - # selfmark = { subdomain = "arr"; subpath = "selfmark"; }; + freshrss.subdomain = "rss"; + suwayomi.subdomain = "manga"; + calibre.subdomain = "books"; + selfmark = { subdomain = "arr"; subpath = "selfmark"; }; favicon.extra = { mappings = { - "home" = { - background = "#0f172a"; - foreground = "#22c55e"; - }; - "cloud" = { - background = "#0b1220"; - foreground = "#38bdf8"; - }; - "sso" = { - background = "#1f1630"; - foreground = "#f59e0b"; - }; - "metrum" = { - background = "#1a1d29"; - foreground = "#a78bfa"; - }; + traefik={bg="base01";fg="low0B";}; + umami={bg="base01";fg="low0B";}; + sso={bg="base01";fg="high08";}; + searx={bg="base01";fg="alt_high0D";}; + home={bg="base01";fg="base07";}; + cloud={bg="base01";fg="high0C";}; + office={bg="base01";fg="alt_high0C";}; + pad={bg="base01";fg="alt_high0C";}; + #calc={bg="base01";fg="alt_high0C";}; + pic={bg="base01";fg="high09";}; + yt={bg="base01";fg="high0F";}; + flix={bg="base01";fg="high0D";}; + arr={bg="base01";fg="low0D";}; + git={bg="base01";fg="high0A";}; + hab={bg="base01";fg="high08";}; + metrum={bg="base01";fg="low0B";}; + rss={bg="base01";fg="high0A";}; + manga={bg="base01";fg="high0E";}; + books={bg="base01";fg="high0E";}; }; default = { - background = "#111827"; - foreground = "#ffffff"; + bg = "base01"; + fg = "base07"; }; }; };