blob: 9c78295d3116d2b256c50059795f70d8eaf3b389 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
{
config,
lib,
pkgs,
...
}: let
cfg = config.collinux.services.btopweb;
btopSettings = pkgs.writeText "btop.conf" ''
color_theme = "tomorrow-night"
enable_mouse = true
background_update = false
proc_tree = true
proc_colors = true
'';
in {
config = lib.mkIf cfg.enable {
users.groups."btopweb" = {};
users.users."btopweb" = {
isSystemUser = true;
group = "btopweb";
};
users.users.caddy.extraGroups = ["btopweb"];
systemd.services."btopweb" = {
description = "Host btop on a website";
restartIfChanged = true;
wants = ["network-online.target"];
after = ["network-online.target"];
wantedBy = ["multi-user.target"];
serviceConfig = {
User = "btopweb";
Group = "btopweb";
Type = "simple";
RuntimeDirectory = "btopweb";
RuntimeDirectoryMode = "0770";
UMask = "0007";
ExecStart = ''
${lib.getExe pkgs.ttyd} \
-W \
-i /run/btopweb/ttyd.sock \
-t renderType=canvas \
-t fontSize=16 \
${pkgs.btop}/bin/btop -c ${btopSettings}
'';
};
};
services.caddy.virtualHosts."btop.ganymede".extraConfig = ''
tls internal
reverse_proxy unix//run/btopweb/ttyd.sock
'';
collinux.services.glance.homelabServices."btop" = {
url = "https://btop.ganymede";
icon = "si:htop";
};
};
}
|