From 54080cfa18c727979dbcabdf584766d5b6455738 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 10 Jun 2025 22:41:23 +0200 Subject: [PATCH] feat(web/portefolio): adding the portefolio configuration to self host --- hosts/server/configuration.nix | 2 ++ services/web.nix | 21 +++++++++++++++ services/web/portefolio.nix | 48 ++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 services/web.nix create mode 100644 services/web/portefolio.nix diff --git a/hosts/server/configuration.nix b/hosts/server/configuration.nix index 5cd2e34..ca9529a 100644 --- a/hosts/server/configuration.nix +++ b/hosts/server/configuration.nix @@ -7,6 +7,7 @@ ../../modules/games/global.nix ../../services/discord.nix ../../services/games.nix + ../../services/web.nix ]; networking = { @@ -17,6 +18,7 @@ }; service = { + web.portefolio = true; minecraft = { enium-pv = false; }; diff --git a/services/web.nix b/services/web.nix new file mode 100644 index 0000000..43712f7 --- /dev/null +++ b/services/web.nix @@ -0,0 +1,21 @@ +{ inputs, config, pkgs, lib, ... }: + +let + portefolio = import ./web/portefolio.nix { + inherit inputs config pkgs lib; + }; + cfg = config.service.web; +in +{ + imports = [ + portefolio + ]; + + options.service.web = { + portefolio = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Enable the portefolio"; + }; + }; +} diff --git a/services/web/portefolio.nix b/services/web/portefolio.nix new file mode 100644 index 0000000..7944783 --- /dev/null +++ b/services/web/portefolio.nix @@ -0,0 +1,48 @@ +{ config, pkgs, lib, ... }: + +let + cfg = config.service.web.portefolio; +in +{ + config = lib.mkIf cfg { + environment.systemPackages = with pkgs; [ + nodejs + pnpm + ]; + users = { + groups.web_portefolio = { + name = "web_portefolio"; + }; + users.web_portefolio = { + description = "Utilisateur pour le bot BDE"; + group = "web_portefolio"; + home = "/opt/portefolio/"; + isSystemUser = true; + }; + }; + + services.nginx = { + enable = true; + recommendedGzipSettings = true; + recommendedProxySettings = true; + virtualHosts."raphael.parodi.pro" = { + forceSSL = true; + enableACME = true; + locations."/" = { + root = "/opt/portefolio/dist"; + index = "index.html"; + extraConfig = '' + try_files $uri /index.html; + ''; + }; + }; + }; + security.acme = { + acceptTerms = true; + email = "raphael@parodi.pro"; + certs = { + "raphael.parodi.pro" = {}; + }; + }; + }; +}