glance: Add github action badges widget

This commit is contained in:
SebastianStork 2026-03-12 21:12:55 +01:00
parent 52580f096d
commit 1bb4b6db32
Signed by: SebastianStork
SSH key fingerprint: SHA256:tRrGdjYOwgHxpSc/wTOZQZEjxcb15P0tyXRsbAfd+2Q

View file

@ -16,7 +16,7 @@ let
hosts = allHosts |> lib.attrValues; hosts = allHosts |> lib.attrValues;
applicationSites = applicationSitesWidget =
hosts hosts
|> lib.concatMap (host: host.config.custom.meta.sites |> lib.attrValues) |> lib.concatMap (host: host.config.custom.meta.sites |> lib.attrValues)
|> lib.filter (service: !lib.elem service.title observabilityTitles) |> lib.filter (service: !lib.elem service.title observabilityTitles)
@ -36,10 +36,9 @@ let
type = "split-column"; type = "split-column";
max-columns = 2; max-columns = 2;
inherit widgets; inherit widgets;
}) });
|> lib.singleton;
observabilitySites = observabilitySitesWidget =
hosts hosts
|> lib.map (host: { |> lib.map (host: {
type = "monitor"; type = "monitor";
@ -55,48 +54,48 @@ let
type = "split-column"; type = "split-column";
max-columns = widgets |> lib.length; max-columns = widgets |> lib.length;
inherit widgets; inherit widgets;
}) });
|> lib.singleton;
in githubWorkflowFiles =
{ "${self}/.github/workflows"
options.custom.web-services.glance = { |> builtins.readDir
enable = lib.mkEnableOption ""; |> lib.attrNames
domain = lib.mkOption { |> lib.filter (file: file |> lib.hasSuffix ".yml")
type = lib.types.nonEmptyStr; |> lib.filter (file: file |> lib.hasPrefix "_" |> (hasPrefix: !hasPrefix));
default = "";
}; mkGithubWorkflowBadge =
port = lib.mkOption { workflowFile:
type = lib.types.port; let
default = 63958; workflowName = workflowFile |> lib.removeSuffix ".yml";
}; workflowUrl = "https://github.com/SebastianStork/nixos-config/actions/workflows/${workflowFile}";
in
''
<a class="block" href="${workflowUrl}" target="_blank" rel="noopener noreferrer">
<img
class="block"
src="${workflowUrl}/badge.svg"
alt="${workflowName} workflow status"
/>
</a>
'';
githubWorkflowBadges =
githubWorkflowFiles |> lib.map mkGithubWorkflowBadge |> lib.concatStringsSep "\n";
githubBadgeWidget = {
type = "custom-api";
title = "nixos-config";
title-url = "https://github.com/SebastianStork/nixos-config";
template = ''
<div class="flex flex-col items-start gap-10">
<div class="flex flex-wrap gap-10">
${githubWorkflowBadges}
</div>
</div>
'';
}; };
config = lib.mkIf cfg.enable { bookmarksWidget = {
services.glance = {
enable = true;
settings = {
server.port = cfg.port;
pages = lib.singleton {
name = "Home";
center-vertically = true;
columns = [
{
size = "full";
widgets =
lib.singleton {
type = "search";
search-engine = "https://search.splitleaf.de/search?q={QUERY}";
autofocus = true;
}
++ applicationSites
++ observabilitySites;
}
{
size = "small";
widgets = lib.singleton {
type = "bookmarks"; type = "bookmarks";
groups = [ groups = [
{ {
@ -162,7 +161,7 @@ in
} }
{ {
title = "Function Search"; title = "Function Search";
url = "https://home-manager-options.extranix.com/"; url = "https://noogle.dev/";
} }
{ {
title = "GitHub Code Search"; title = "GitHub Code Search";
@ -212,6 +211,50 @@ in
} }
]; ];
}; };
in
{
options.custom.web-services.glance = {
enable = lib.mkEnableOption "";
domain = lib.mkOption {
type = lib.types.nonEmptyStr;
default = "";
};
port = lib.mkOption {
type = lib.types.port;
default = 63958;
};
};
config = lib.mkIf cfg.enable {
services.glance = {
enable = true;
settings = {
server.port = cfg.port;
pages = lib.singleton {
name = "Home";
center-vertically = true;
columns = [
{
size = "full";
widgets = [
{
type = "search";
search-engine = "https://search.splitleaf.de/search?q={QUERY}";
autofocus = true;
}
applicationSitesWidget
observabilitySitesWidget
];
}
{
size = "small";
widgets = [
githubBadgeWidget
bookmarksWidget
];
} }
]; ];
}; };