diff --git a/flake.nix b/flake.nix index 95563c8..a2e7fa5 100644 --- a/flake.nix +++ b/flake.nix @@ -43,6 +43,28 @@ RUST_SRC_PATH = rustPlatform.rustLibSrc; }; - }); + nixosModule = { config, lib }: { + options.xeserv.mara-bot.enable = lib.mkEnableOption "enable Mara bot"; + config = lib.mkIf config.xeserv.mara-bot.enable { + users.users.mara-bot = { + createHome = true; + isSystemUser = true; + home = "/var/lib/mara-bot"; + }; + + systemd.services.mara-bot = { + wantedBy = [ "multi-user.target" ]; + environment.RUST_LOG = "tower_http=debug,info"; + serviceConfig = { + User = "mara-bot"; + Group = "mara-bot"; + Restart = "always"; + ConditionPathExists = "/var/lib/mara-bot/config.yaml"; + WorkingDirectory = "/var/lib/mara-bot"; + }; + }; + }; + }; + }); }