glados/glados-module.nix

39 lines
1.1 KiB
Nix
Raw Normal View History

2021-12-05 11:35:20 +01:00
{ pkgs, lib, config, ... }:
let
cfg = config.services.glados;
ownerArgs = list: toString (map (id: "--owner ${id}") list);
2021-12-09 18:03:57 +01:00
enableDataCollector =
if cfg.dataCollector.enable then "--enable-data-collector" else "";
2021-12-05 11:35:20 +01:00
in {
options.services.glados = {
enable = lib.mkEnableOption "GLaDOS systemd service";
2021-12-09 18:03:57 +01:00
dataCollector.enable =
lib.mkEnableOption "Enable Minecraft -> InfluxDB data collector";
2021-12-06 10:49:27 +01:00
envFile = lib.mkOption {
type = lib.types.str;
description = "Path to the environment configuration";
example = "/run/secrets/my-env";
2021-12-05 11:35:20 +01:00
};
};
2021-12-05 12:05:40 +01:00
config = lib.mkIf cfg.enable {
2021-12-05 11:35:20 +01:00
systemd.services.glados = {
wantedBy = [ "default.target" ];
2021-12-06 11:30:35 +01:00
requires = [ "network-online.target" ];
after = [ "network-online.target" ];
2021-12-05 11:35:20 +01:00
serviceConfig = {
2021-12-09 18:03:57 +01:00
ExecStart =
"${pkgs.glados}/bin/glados --state $STATE_DIRECTORY/state.yml ${enableDataCollector}";
2021-12-06 10:49:27 +01:00
EnvironmentFile = "${cfg.envFile}";
Environment = "RUST_LOG=warn";
StateDirectory = "glados";
2021-12-06 11:30:35 +01:00
Restart = "always";
2021-12-05 11:35:20 +01:00
};
};
};
}