summaryrefslogtreecommitdiff
path: root/module.nix
blob: f1435c4957b1c2894d35e64d79ca1b0e943be133 (plain) (blame)
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
{ config, pkgs, lib, system, self, ... }:
let cfg = config.services.nuogai;
in with lib; {
  options.services.nuogai = {
    enable = mkEnableOption "Enables the nuogaı Discord Bot";
    toaduaHost = mkOption { type = types.str; };
    zugaiHost = mkOption { type = types.str; };
    tokenPath = mkOption { type = types.path; };
  };
  config = {
    fonts.fonts = optionals cfg.enable [ self.packages.${system}.toaqScript ];
    services.nuogai.zugaiHost = lib.mkDefault "https://zugai.toaq.me";
    systemd.services.nuogai = {
      inherit (cfg) enable;
      description = "Toaq Discord bot";
      wantedBy = [ "multi-user.target" ];
      wants = [ "network-online.target" ];
      environment = {
        TOADUA_HOST = cfg.toaduaHost;
        ZUGAI_HOST = cfg.zugaiHost;
      };
      script = ''
        export NUOGAI_TOKEN=$(cat ${cfg.tokenPath})
        ${self.packages.${system}.nuogai}/bin/nuogai
      '';
    };
  };
}