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;
applicationSites =
applicationSitesWidget =
hosts
|> lib.concatMap (host: host.config.custom.meta.sites |> lib.attrValues)
|> lib.filter (service: !lib.elem service.title observabilityTitles)
@ -36,10 +36,9 @@ let
type = "split-column";
max-columns = 2;
inherit widgets;
})
|> lib.singleton;
});
observabilitySites =
observabilitySitesWidget =
hosts
|> lib.map (host: {
type = "monitor";
@ -55,48 +54,48 @@ let
type = "split-column";
max-columns = widgets |> lib.length;
inherit widgets;
})
|> lib.singleton;
});
githubWorkflowFiles =
"${self}/.github/workflows"
|> builtins.readDir
|> lib.attrNames
|> lib.filter (file: file |> lib.hasSuffix ".yml")
|> lib.filter (file: file |> lib.hasPrefix "_" |> (hasPrefix: !hasPrefix));
mkGithubWorkflowBadge =
workflowFile:
let
workflowName = workflowFile |> lib.removeSuffix ".yml";
workflowUrl = "https://github.com/SebastianStork/nixos-config/actions/workflows/${workflowFile}";
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;
};
''
<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 {
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 {
bookmarksWidget = {
type = "bookmarks";
groups = [
{
@ -162,7 +161,7 @@ in
}
{
title = "Function Search";
url = "https://home-manager-options.extranix.com/";
url = "https://noogle.dev/";
}
{
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
];
}
];
};