From: Ismaël Bouya Date: Sun, 7 Jun 2020 16:46:27 +0000 (+0200) Subject: Add comment engine X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FConfig%2FNix.git;a=commitdiff_plain;h=6338573a8a4b416d5bce384dac712197f90637dc Add comment engine --- diff --git a/modules/private/default.nix b/modules/private/default.nix index 21b9845..bcd6e23 100644 --- a/modules/private/default.nix +++ b/modules/private/default.nix @@ -71,6 +71,7 @@ set = { # Tools cloudTool = ./websites/tools/cloud; + commentoTool = ./websites/tools/commento; davTool = ./websites/tools/dav; vpnTool = ./websites/tools/vpn; dbTool = ./websites/tools/db; diff --git a/modules/private/environment.nix b/modules/private/environment.nix index ec9bf29..82e3981 100644 --- a/modules/private/environment.nix +++ b/modules/private/environment.nix @@ -108,6 +108,19 @@ let }; }; }; + smtpOptions = { + host = mkOption { description = "Host to access SMTP"; type = str; }; + port = mkOption { description = "Port to access SMTP"; type = str; }; + }; + mkSmtpOptions = name: mkOption { + description = "${name} smtp configuration"; + type = submodule { + options = smtpOptions // { + email = mkOption { description = "${name} email"; type = str; }; + password = mkOption { description = "SMTP password of the ${name} user"; type = str; }; + }; + }; + }; hostEnv = submodule { options = { fqdn = mkOption { @@ -258,6 +271,10 @@ in }; }; }; + smtp = mkOption { + type = submodule { options = smtpOptions; }; + description = "SMTP configuration"; + }; ldap = mkOption { description = '' LDAP server configuration @@ -1051,6 +1068,16 @@ in type = attrsOf str; description = "Mapping 'name'.php => script for webhooks"; }; + commento = mkOption { + description = "Commento configuration"; + type = submodule { + options = { + listenPort = mkOption { type = port; description = "Port to listen to"; }; + postgresql = mkPsqlOptions "Commento"; + smtp = mkSmtpOptions "Commento"; + }; + }; + }; ympd = mkOption { description = "Ympd configuration"; type = submodule { diff --git a/modules/private/websites/default.nix b/modules/private/websites/default.nix index 27719cc..d55d2dd 100644 --- a/modules/private/websites/default.nix +++ b/modules/private/websites/default.nix @@ -284,6 +284,7 @@ in telio_tortay.production.enable = true; tools.cloud.enable = true; + tools.commento.enable = true; tools.dav.enable = true; tools.db.enable = true; tools.diaspora.enable = true; diff --git a/modules/private/websites/immae/history/_posts/2020-06-06-Moteur-de-commentaires.md b/modules/private/websites/immae/history/_posts/2020-06-06-Moteur-de-commentaires.md new file mode 100644 index 0000000..6778326 --- /dev/null +++ b/modules/private/websites/immae/history/_posts/2020-06-06-Moteur-de-commentaires.md @@ -0,0 +1,9 @@ +--- +title: "Moteur de commentaires" +category: Nouveautés +date: 2020-06-06 +--- +Un [nouveau moteur de commentaires](https://commento.immae.eu) a été +installé, pour obtenir une fonctionnalité similaire à des outils tels +que disqus. Il est pour l’instant uilisé pour le +[blog](https://www.immae.eu/blog) et le [livre de recettes](https://www.immae.eu/recettes) diff --git a/modules/private/websites/tools/commento/default.nix b/modules/private/websites/tools/commento/default.nix new file mode 100644 index 0000000..d0e7d24 --- /dev/null +++ b/modules/private/websites/tools/commento/default.nix @@ -0,0 +1,60 @@ +{ lib, pkgs, config, ... }: +let + cfg = config.myServices.websites.tools.commento; + env = config.myEnv.tools.commento; + webPort = "${host}:${port}"; + port = toString env.listenPort; + host = "localhost"; + postgresql_url = "postgres://${env.postgresql.user}:${env.postgresql.password}@localhost:${env.postgresql.port}/${env.postgresql.database}?sslmode=disable"; +in +{ + options.myServices.websites.tools.commento = { + enable = lib.mkEnableOption "Enable commento website"; + }; + config = lib.mkIf cfg.enable { + secrets.keys = [ + { + dest = "commento/env"; + permission = "0400"; + text = '' + COMMENTO_ORIGIN=https://commento.immae.eu/ + COMMENTO_PORT=${port} + COMMENTO_POSTGRES=${postgresql_url} + COMMENTO_FORBID_NEW_OWNERS=true + COMMENTO_BIND_ADDRESS=${host} + COMMENTO_GZIP_STATIC=true + COMMENTO_SMTP_HOST=${env.smtp.host} + COMMENTO_SMTP_PORT=${env.smtp.port} + COMMENTO_SMTP_USERNAME=${env.smtp.email} + COMMENTO_SMTP_PASSWORD=${env.smtp.password} + COMMENTO_SMTP_FROM_ADDRESS=${env.smtp.email} + ''; + } + ]; + + services.websites.env.tools.vhostConfs.commento = { + certName = "eldiron"; + addToCerts = true; + hosts = [ "commento.immae.eu" ]; + root = null; + extraConfig = [ + '' + ProxyPass / http://${webPort}/ + ProxyPassReverse / http://${webPort}/ + ProxyPreserveHost On + '' + ]; + }; + systemd.services.commento = { + description = "Commento"; + wantedBy = [ "multi-user.target" ]; + requires = ["postgresql.service"]; + after = ["network.target" "postgresql.service"]; + serviceConfig = { + User = "wwwrun"; + ExecStart = "${pkgs.commento}/commento"; + EnvironmentFile = config.secrets.fullPaths."commento/env"; + }; + }; + }; +} diff --git a/modules/private/websites/tools/tools/landing/config.yml b/modules/private/websites/tools/tools/landing/config.yml index f3de6fc..e86dc19 100644 --- a/modules/private/websites/tools/tools/landing/config.yml +++ b/modules/private/websites/tools/tools/landing/config.yml @@ -71,6 +71,9 @@ services: - name: "Social" icon: "fas fa-users" items: + - name: "Commento" + logo: "assets/tools/commento.svg" + url: "https://commento.immae.eu" - name: "Diaspora" logo: "assets/tools/diaspora.png" url: "https://diaspora.immae.eu" diff --git a/modules/private/websites/tools/tools/landing/icons/commento.svg b/modules/private/websites/tools/tools/landing/icons/commento.svg new file mode 100644 index 0000000..39da47a --- /dev/null +++ b/modules/private/websites/tools/tools/landing/icons/commento.svg @@ -0,0 +1,10 @@ + + + +assets + + + + + + diff --git a/pkgs/commento/default.nix b/pkgs/commento/default.nix new file mode 100644 index 0000000..6361583 --- /dev/null +++ b/pkgs/commento/default.nix @@ -0,0 +1,20 @@ +{ stdenv, fetchurl, patchelfUnstable, autoPatchelfHook }: +stdenv.mkDerivation rec { + pname = "commento"; + version = "v1.8.0"; + name = "${pname}-${version}"; + src = fetchurl { + url = "https://dl.commento.io/release/${name}-linux-glibc-amd64.tar.gz"; + sha256 = "1j88b16hdx3i8nsq56581cscij65slgbsa6yfj73ybbg1585axxs"; + }; + phases = [ "unpackPhase" "installPhase" "fixupPhase" ]; + unpackPhase = '' + tar --one-top-level=${name} -xf "$src" + ''; + installPhase = '' + cp -a ${name} $out + ''; + postFixup = '' + ${patchelfUnstable}/bin/patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/commento + ''; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index 3b0e937..03fee4f 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -8,6 +8,7 @@ rec { myEnvironments = callPackage ../environments {}; boinctui = callPackage ./boinctui {}; cnagios = callPackage ./cnagios { inherit mylibs; }; + commento = callPackage ./commento {}; duply = callPackage ./duply {}; flrn = callPackage ./flrn { inherit mylibs; slang = callPackage ./slang_1 {}; }; genius = callPackage ./genius {};