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