~james/core

core/nix/modules/cilogs.nix -rw-r--r-- 1.5 KiB
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 16 hours ago
                                                                                
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
{
  config,
  lib,
  ...
}: let
  cfg = config.services.tangled.cilogs;
in
  with lib; {
    options.services.tangled.cilogs = {
      enable = mkEnableOption "ssh server that follows a ci run's logs in a terminal";

      package = mkOption {
        type = types.package;
        description = "cilogs package to run";
      };

      listenAddr = mkOption {
        type = types.str;
        default = "0.0.0.0:3333";
        description = "address the ssh server listens on, the host:port a spindle's logsAddr names";
      };

      hostKeyPath = mkOption {
        type = types.str;
        default = "/var/lib/cilogs/ssh_host_ed25519_key";
        description = "ssh host key, made on first start when missing";
      };

      plcUrl = mkOption {
        type = types.str;
        default = "https://plc.directory";
        description = "plc directory that resolves repo dids";
      };
    };

    config = mkIf cfg.enable {
      systemd.services.cilogs = {
        description = "tangled ci logs over ssh";
        after = ["network-online.target"];
        wants = ["network-online.target"];
        wantedBy = ["multi-user.target"];
        serviceConfig = {
          Environment = [
            "CILOGS_LISTEN_ADDR=${cfg.listenAddr}"
            "CILOGS_HOST_KEY_PATH=${cfg.hostKeyPath}"
            "CILOGS_PLC_URL=${cfg.plcUrl}"
          ];
          ExecStart = getExe cfg.package;
          Restart = "always";
          DynamicUser = true;
          StateDirectory = "cilogs";
        };
      };
    };
  }