Skip to content

Commit fd49947

Browse files
stackptrclaude
andcommitted
feat(glyph): add agentsview service with PostgreSQL backend
- Add agentsview database and user to PostgreSQL - Add systemd service for agentsview pg serve (team dashboard on :8095) - Add systemd timer to push local glyph sessions every 10 minutes - Tailscale subnet trusted for passwordless PG access Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 29da90e commit fd49947

File tree

3 files changed

+63
-2
lines changed

3 files changed

+63
-2
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
config,
3+
pkgs,
4+
...
5+
}: let
6+
port = 8095;
7+
configFile = pkgs.writeText "agentsview-config.toml" ''
8+
[pg]
9+
url = "postgres://agentsview@localhost:5432/agentsview?sslmode=disable"
10+
machine_name = "glyph"
11+
'';
12+
in {
13+
# Serve the aggregated team dashboard from PostgreSQL
14+
systemd.services.agentsview = {
15+
description = "Agentsview team dashboard";
16+
after = ["postgresql.service"];
17+
requires = ["postgresql.service"];
18+
wantedBy = ["multi-user.target"];
19+
serviceConfig = {
20+
ExecStart = "${pkgs.agentsview}/bin/agentsview pg serve -host 127.0.0.1 -port ${toString port}";
21+
DynamicUser = true;
22+
User = "agentsview";
23+
Group = "agentsview";
24+
StateDirectory = "agentsview";
25+
RuntimeDirectory = "agentsview";
26+
Environment = "HOME=/var/lib/agentsview";
27+
ExecStartPre = "+${pkgs.coreutils}/bin/install -Dm640 -o agentsview -g agentsview ${configFile} /var/lib/agentsview/.agentsview/config.toml";
28+
Restart = "on-failure";
29+
RestartSec = 5;
30+
};
31+
};
32+
33+
# Push local glyph sessions to PostgreSQL every 10 minutes
34+
systemd.timers.agentsview-pg-push = {
35+
description = "Push agentsview sessions to PostgreSQL";
36+
wantedBy = ["timers.target"];
37+
timerConfig = {
38+
OnBootSec = "2min";
39+
OnUnitActiveSec = "10min";
40+
Persistent = true;
41+
};
42+
};
43+
44+
systemd.services.agentsview-pg-push = {
45+
description = "Push agentsview sessions to PostgreSQL";
46+
after = ["postgresql.service"];
47+
requires = ["postgresql.service"];
48+
serviceConfig = {
49+
Type = "oneshot";
50+
ExecStart = "${pkgs.agentsview}/bin/agentsview pg push";
51+
User = "mu";
52+
Group = "users";
53+
Environment = "HOME=/home/mu";
54+
};
55+
};
56+
}

hosts/glyph/services/db.nix

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@
1212
port = 5432;
1313
max_connections = 150;
1414
};
15-
ensureDatabases = ["atticd" "grafana" "open-webui" "pocketid"];
15+
ensureDatabases = ["agentsview" "atticd" "grafana" "open-webui" "pocketid"];
1616
ensureUsers = [
1717
{
1818
name = "mu";
1919
ensureClauses.superuser = true;
2020
}
21+
{
22+
name = "agentsview";
23+
ensureDBOwnership = true;
24+
}
2125
{
2226
name = "atticd";
2327
ensureDBOwnership = true;
@@ -39,6 +43,6 @@
3943

4044
services.postgresqlBackup = {
4145
enable = true;
42-
databases = ["atticd" "grafana" "open-webui" "pocketid"];
46+
databases = ["agentsview" "atticd" "grafana" "open-webui" "pocketid"];
4347
};
4448
}

hosts/glyph/services/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
...
55
}: {
66
imports = [
7+
./agentsview.nix
78
./attic.nix
89
./db.nix
910
./avahi.nix

0 commit comments

Comments
 (0)