botoh/nix/module.nix

49 lines
1 KiB
Nix
Raw Normal View History

2024-05-14 22:31:32 -04:00
{self}: {
pkgs,
config,
lib,
...
}: let
inherit (lib) types;
inherit (lib.modules) mkIf;
inherit (lib.options) mkOption mkEnableOption;
inherit (pkgs.stdenv.hostPlatform) system;
2024-05-14 22:45:49 -04:00
cfg = config.services.botoh;
2024-05-14 22:31:32 -04:00
in {
options.services.botoh = {
enable = mkEnableOption ''
Enable botoh
'';
package = mkOption {
type = types.package;
inherit (self.packages.${system}) default;
};
2024-06-16 08:45:57 -04:00
log_level = mkOption {
type = types.str;
default = "info";
};
2024-06-16 02:53:22 -04:00
environmentFiles = mkOption {
type = types.listOf types.path;
default = [];
example = ["/run/twitch_auth"];
description = ''
set twitch oauth / id
'';
2024-06-16 02:30:20 -04:00
};
2024-05-14 22:31:32 -04:00
};
config = mkIf cfg.enable {
2024-05-14 22:45:49 -04:00
systemd.services.botoh = {
2024-05-14 22:31:32 -04:00
wantedBy = ["multi-user.target"];
2024-06-16 08:45:57 -04:00
environment = {
RUST_LOG = cfg.log_level;
};
2024-06-16 02:53:22 -04:00
serviceConfig = {
EnvironmentFile = cfg.environmentFiles;
ExecStart = "${cfg.package}/bin/botoh";
2024-06-16 02:30:20 -04:00
};
2024-05-14 22:31:32 -04:00
};
};
}