From a1bc1e40748397c76f07f57041ea79e53095a118 Mon Sep 17 00:00:00 2001 From: Raphael Date: Sun, 22 Jun 2025 18:34:40 +0200 Subject: [PATCH] feat(42/irc): setup the irc server service --- hosts/global.nix | 1 + hosts/server/configuration.nix | 2 ++ services/bot_discord/master.nix | 8 ++++-- services/forty_two.nix | 21 +++++++++++++++ services/forty_two/irc.nix | 45 +++++++++++++++++++++++++++++++++ 5 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 services/forty_two.nix create mode 100644 services/forty_two/irc.nix diff --git a/hosts/global.nix b/hosts/global.nix index c213314..b05ed31 100644 --- a/hosts/global.nix +++ b/hosts/global.nix @@ -57,6 +57,7 @@ programs = { zsh.enable = true; }; + environment.systemPackages = with pkgs; [ bat cairo diff --git a/hosts/server/configuration.nix b/hosts/server/configuration.nix index 898d090..eb36fb7 100644 --- a/hosts/server/configuration.nix +++ b/hosts/server/configuration.nix @@ -5,6 +5,7 @@ ../global.nix ./hardware-configuration.nix ../../modules/games/global.nix + ../../services/forty_two.nix ../../services/discord.nix ../../services/games.nix ../../services/web.nix @@ -18,6 +19,7 @@ }; service = { + forty_two.irc = true; web.portefolio = true; minecraft = { enium-pv = false; diff --git a/services/bot_discord/master.nix b/services/bot_discord/master.nix index c54658a..10e7c1c 100644 --- a/services/bot_discord/master.nix +++ b/services/bot_discord/master.nix @@ -21,8 +21,12 @@ in }; systemd.services.yagpdb = { description = "Enium discord master bot"; - after = [ "network.target" ]; - wantedBy = [ "multi-user.target" ]; + after = [ + "network.target" + ]; + wantedBy = [ + "multi-user.target" + ]; serviceConfig = { Type = "simple"; User = "dsc_master"; diff --git a/services/forty_two.nix b/services/forty_two.nix new file mode 100644 index 0000000..879cf6d --- /dev/null +++ b/services/forty_two.nix @@ -0,0 +1,21 @@ +{ config, pkgs, lib, ... }: + +let + irc = import ./forty_two/irc.nix { + inherit config pkgs lib; + }; + cfg = config.service.forty_two; +in +{ + imports = [ + irc + ]; + + options.service.forty_two = { + irc = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Enable the ft_irc server"; + }; + }; +} diff --git a/services/forty_two/irc.nix b/services/forty_two/irc.nix new file mode 100644 index 0000000..3740694 --- /dev/null +++ b/services/forty_two/irc.nix @@ -0,0 +1,45 @@ +{ config, pkgs, lib, ... }: + +let + cfg = config.service.forty_two.irc; +in +{ + config = lib.mkIf cfg { + environment.systemPackages = with pkgs; [ + llvmPackages.clang + llvmPackages.clang-tools + gnumake + ]; + users = { + groups.ft_irc = { + name = "ft_irc"; + }; + users.ft_irc = { + description = "Utilisateur the ft_irc server"; + group = "ft_irc"; + home = "/opt/irc/"; + isSystemUser = true; + }; + }; + + systemd.services.ft_irc = { + description = "Upload our irc on my own server"; + after = [ + "network.target" + ]; + wantedBy = [ + "multi-user.target" + ]; + serviceConfig = { + Type = "simple"; + User = "ft_irc"; + WorkingDirectory = "/opt/irc"; + ExecStartPre = "${pkgs.git}/bin/git pull"; + ExecStart = "/opt/irc/ircserv 4243 irc"; + Restart = "on-failure"; + RestartSec = 30; + RemainAfterExit = false; + }; + }; + }; +}