aboutsummaryrefslogtreecommitdiff
path: root/modules/services/nixos/btopweb.nix
blob: 1975c5d1f3bf9353387f49bdb0d884eb5653952c (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
{
  config,
  lib,
  pkgs,
  ...
}: let
  cfg = config.collinux.services.btopweb;
in {
  imports = [
    (import ./mkCaddyCfg.nix cfg)
  ];

  config = lib.mkIf cfg.enable {
    users.groups."btopweb" = {};
    users.users."btopweb" = {
      isSystemUser = true;
      group = "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";
        Type = "simple";

        ExecStart = "${pkgs.gotty}/bin/gotty --reconnect --port ${toString cfg.port} ${pkgs.btop}/bin/btop";
      };
    };
  };
}