From dc684436618ebec1933039f5ec7790c866d8c527 Mon Sep 17 00:00:00 2001 From: Raphael Date: Sun, 15 Jun 2025 14:51:12 +0200 Subject: [PATCH] feat(discord/marty): adding marty to the configuration --- hosts/server/configuration.nix | 1 + services/bot_discord/marty.nix | 47 ++++++++++++++++++++++++++++++++++ services/discord.nix | 9 +++++++ 3 files changed, 57 insertions(+) create mode 100644 services/bot_discord/marty.nix diff --git a/hosts/server/configuration.nix b/hosts/server/configuration.nix index ca9529a..898d090 100644 --- a/hosts/server/configuration.nix +++ b/hosts/server/configuration.nix @@ -25,6 +25,7 @@ bot_discord = { master = true; bde = true; + marty = true; ada = true; music = false; tempvoc = true; diff --git a/services/bot_discord/marty.nix b/services/bot_discord/marty.nix new file mode 100644 index 0000000..1955406 --- /dev/null +++ b/services/bot_discord/marty.nix @@ -0,0 +1,47 @@ +{ config, pkgs, lib, ... }: + +let + cfg = config.service.bot_discord.marty; +in +{ + config = lib.mkIf cfg { + environment.systemPackages = with pkgs; [ + nodejs + ]; + users = { + groups.dsc_marty = { + name = "dsc_marty"; + }; + users.dsc_marty = { + description = "Utilisateur pour le bot BDE"; + group = "dsc_marty"; + home = "/opt/marty"; + isSystemUser = true; + }; + }; + + systemd.services.bot_marty = { + description = "marty discord bot"; + after = [ + "network.target" + ]; + wantedBy = [ + "multi-user.target" + ]; + serviceConfig = { + Type = "simple"; + User = "dsc_marty"; + WorkingDirectory = "/opt/marty"; + Environment = "PATH=${pkgs.coreutils}/bin:${pkgs.bash}/bin:${pkgs.nodejs}/bin"; + ExecStartPre = [ + "${pkgs.nodejs}/bin/npm install" + "${pkgs.nodejs}/bin/npm run build" + ]; + ExecStart = "${pkgs.nodejs}/bin/npm run start-prod"; + EnvironmentFile = "/opt/marty/.env"; + Restart = "on-failure"; + RestartSec = 5; + }; + }; + }; +} diff --git a/services/discord.nix b/services/discord.nix index b426bb3..b008f00 100644 --- a/services/discord.nix +++ b/services/discord.nix @@ -16,6 +16,9 @@ let bde_bot = import ./bot_discord/bde.nix { inherit config pkgs lib; }; + marty_bot = import ./bot_discord/marty.nix { + inherit config pkgs lib; + }; ticket_bot = import ./bot_discord/ticket.nix { inherit config pkgs lib; }; @@ -29,6 +32,7 @@ in music_bot tempvoc_bot ticket_bot + marty_bot ]; options.service.bot_discord = { @@ -47,6 +51,11 @@ in default = false; description = "Enable bde bot"; }; + marty = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Enable marty bot"; + }; music = lib.mkOption { type = lib.types.bool; default = false;