X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=virtual%2Feldiron.nix;h=c1a7761c3802aebebdf98b84045a400b3f78e259;hb=6f0d92b429069069e6d914f25bb30a549526f9d8;hp=30face7aa65529c1a60bc94f3bb6873e197061f0;hpb=91493dc0e93b89a24617738ca466e12957143eb0;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/virtual/eldiron.nix b/virtual/eldiron.nix index 30face7..c1a7761 100644 --- a/virtual/eldiron.nix +++ b/virtual/eldiron.nix @@ -5,13 +5,29 @@ }; eldiron = { config, pkgs, ... }: - let mypkgs = import ./packages.nix; - mylibs = import ../libs.nix; + with import ../libs.nix; + let + mypkgs = pkgs.callPackage ./packages.nix { + inherit checkEnv fetchedGitPrivate fetchedGithub; + }; in { - # FIXME: they are not overriden in packages.nix - # (see nix-store -q --tree /nix/var/nix/profiles/system) nixpkgs.config.packageOverrides = oldpkgs: rec { + gitolite = oldpkgs.gitolite.overrideAttrs(old: rec { + name = "gitolite-${version}"; + version = "3.6.10"; + src = pkgs.fetchFromGitHub { + owner = "sitaramc"; + repo = "gitolite"; + rev = "v${version}"; + sha256 = "0p2697mn6rwm03ndlv7q137zczai82n41aplq1g006ii7f12xy8h"; + }; + }); + gitweb = oldpkgs.gitweb.overrideAttrs(old: { + installPhase = old.installPhase + '' + cp -r ${./packages/gitweb} $out/gitweb-theme; + ''; + }); postgresql = postgresql111; postgresql111 = oldpkgs.postgresql100.overrideAttrs(old: rec { passthru = old.passthru // { psqlSchema = "11.0"; }; @@ -26,6 +42,16 @@ cmakeFlags = old.cmakeFlags ++ [ "-DWITH_AUTHENTICATION_PAM=ON" ]; buildInputs = old.buildInputs ++ [ pkgs.pam ]; }); + goaccess = oldpkgs.goaccess.overrideAttrs(old: rec { + name = "goaccess-${version}"; + version = "1.3"; + src = pkgs.fetchurl { + url = "https://tar.goaccess.io/${name}.tar.gz"; + sha256 = "16vv3pj7pbraq173wlxa89jjsd279004j4kgzlrsk1dz4if5qxwc"; + }; + configureFlags = old.configureFlags ++ [ "--enable-tcb=btree" ]; + buildInputs = old.buildInputs ++ [ pkgs.tokyocabinet pkgs.bzip2 ]; + }); }; networking = { @@ -69,10 +95,13 @@ in [ pkgs.telnet pkgs.vim + pkgs.goaccess occ ]; security.acme.certs = { + # /!\ To create a new certificate, add first the domain to an + # existing certificate, deploy, and then use it in httpd. "eldiron" = { webroot = "/var/lib/acme/acme-challenge"; email = "ismael@bouya.org"; @@ -88,6 +117,32 @@ "connexionswing.immae.eu" = null; "sandetludo.immae.eu" = null; "cloud.immae.eu" = null; + "ludivine.immae.eu" = null; + "dev.aten.pro" = null; + }; + }; + "ludivinecassal" = { + webroot = "/var/lib/acme/acme-challenge"; + email = "ismael@bouya.org"; + domain = "ludivinecassal.com"; + plugins = [ "cert.pem" "chain.pem" "fullchain.pem" "full.pem" "key.pem" "account_key.json" ]; + postRun = '' + systemctl reload httpd.service + ''; + extraDomains = { + "www.ludivinecassal.com" = null; + }; + }; + "aten" = { + webroot = "/var/lib/acme/acme-challenge"; + email = "ismael@bouya.org"; + domain = "aten.pro"; + plugins = [ "cert.pem" "chain.pem" "fullchain.pem" "full.pem" "key.pem" "account_key.json" ]; + postRun = '' + systemctl reload httpd.service + ''; + extraDomains = { + "www.aten.pro" = null; }; }; # "connexionswing" = { @@ -146,6 +201,8 @@ extension=${pkgs.phpPackages.redis}/lib/php/extensions/redis.so ; For nextcloud extension=${pkgs.phpPackages.apcu}/lib/php/extensions/apcu.so + ; For nextcloud + zend_extension=${pkgs.php}/lib/php/extensions/opcache.so ''; extraConfig = '' log_level = notice @@ -154,6 +211,10 @@ adminer = mypkgs.adminer.phpFpm.pool; connexionswing_dev = mypkgs.connexionswing_dev.phpFpm.pool; connexionswing_prod = mypkgs.connexionswing_prod.phpFpm.pool; + ludivinecassal_dev = mypkgs.ludivinecassal_dev.phpFpm.pool; + ludivinecassal_prod = mypkgs.ludivinecassal_prod.phpFpm.pool; + aten_dev = mypkgs.aten_dev.phpFpm.pool; + aten_prod = mypkgs.aten_prod.phpFpm.pool; nextcloud = mypkgs.nextcloud.phpFpm.pool; mantisbt = mypkgs.mantisbt.phpFpm.pool; }; @@ -162,6 +223,10 @@ system.activationScripts = { connexionswing_dev = mypkgs.connexionswing_dev.activationScript; connexionswing_prod = mypkgs.connexionswing_prod.activationScript; + ludivinecassal_dev = mypkgs.ludivinecassal_dev.activationScript; + ludivinecassal_prod = mypkgs.ludivinecassal_prod.activationScript; + aten_dev = mypkgs.aten_dev.activationScript; + aten_prod = mypkgs.aten_prod.activationScript; nextcloud = mypkgs.nextcloud.activationScript; httpd = '' install -d -m 0755 /var/lib/acme/acme-challenge @@ -171,9 +236,9 @@ chown redis /run/redis ''; gitolite = - assert mylibs.checkEnv "NIXOPS_GITOLITE_LDAP_PASSWORD"; + assert checkEnv "NIXOPS_GITOLITE_LDAP_PASSWORD"; let - gitolite_ldap_groups = mylibs.wrap { + gitolite_ldap_groups = wrap { name = "gitolite_ldap_groups.sh"; file = ./packages/gitolite_ldap_groups.sh; vars = { @@ -193,12 +258,16 @@ fi ''; }; + goaccess = '' + mkdir -p /var/lib/goaccess + mkdir -p /var/lib/goaccess/aten.pro + ''; }; environment.etc."ssh/ldap_authorized_keys" = let ldap_authorized_keys = - assert mylibs.checkEnv "NIXOPS_SSHD_LDAP_PASSWORD"; - mylibs.wrap { + assert checkEnv "NIXOPS_SSHD_LDAP_PASSWORD"; + wrap { name = "ldap_authorized_keys"; file = ./ldap_authorized_keys.sh; vars = { @@ -223,11 +292,13 @@ }; services.httpd = let - withSSL = domain: { + withConf = domain: { enableSSL = true; sslServerCert = "/var/lib/acme/${domain}/cert.pem"; sslServerKey = "/var/lib/acme/${domain}/key.pem"; sslServerChain = "/var/lib/acme/${domain}/fullchain.pem"; + logFormat = "combinedVhost"; + listen = [ { ip = "*"; port = 443; } ]; }; apacheConfig = { gzip = { @@ -238,7 +309,7 @@ }; ldap = { modules = [ "ldap" "authnz_ldap" ]; - extraConfig = assert mylibs.checkEnv "NIXOPS_HTTP_LDAP_PASSWORD"; '' + extraConfig = assert checkEnv "NIXOPS_HTTP_LDAP_PASSWORD"; '' LDAPSharedCacheSize 500000 LDAPCacheEntries 1024 @@ -257,6 +328,31 @@ AuthBasicProvider ldap + + + Alias /awstats /var/lib/goaccess/%{domain} + + DirectoryIndex index.html + AllowOverride None + Require all granted + + + Use LDAPConnect + Require ldap-group cn=%{domain},ou=stats,cn=httpd,ou=services,dc=immae,dc=eu + + + ''; + }; + http2 = { + modules = [ "http2" ]; + extraConfig = '' + Protocols h2 http/1.1 + ''; + }; + customLog = { + modules = []; + extraConfig = '' + LogFormat "%v:%p %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedVhost ''; }; }; @@ -265,28 +361,16 @@ logPerVirtualHost = true; multiProcessingModule = "worker"; adminAddr = "httpd@immae.eu"; - # FIXME: http2 - # FIXME: voir les autres modules: - # authz_core_module - # reqtimeout_module - # http2_module - # version_module - # proxy_connect_module - # proxy_ftp_module - # proxy_scgi_module - # proxy_ajp_module - # proxy_balancer_module - # proxy_express_module - # lbmethod_byrequests_module - # lbmethod_bytraffic_module - # lbmethod_bybusyness_module - # lbmethod_heartbeat_module - + logFormat = "combinedVhost"; extraModules = pkgs.lib.lists.unique ( mypkgs.adminer.apache.modules ++ mypkgs.nextcloud.apache.modules ++ mypkgs.connexionswing_dev.apache.modules ++ mypkgs.connexionswing_prod.apache.modules ++ + mypkgs.ludivinecassal_dev.apache.modules ++ + mypkgs.ludivinecassal_prod.apache.modules ++ + mypkgs.aten_dev.apache.modules ++ + mypkgs.aten_prod.apache.modules ++ mypkgs.ympd.apache.modules ++ mypkgs.git.web.apache.modules ++ mypkgs.mantisbt.apache.modules ++ @@ -295,24 +379,21 @@ extraConfig = builtins.concatStringsSep "\n" (pkgs.lib.attrsets.mapAttrsToList (n: v: v.extraConfig) apacheConfig); virtualHosts = [ - (withSSL "eldiron" // { - listen = [ { ip = "*"; port = 443; } ]; + (withConf "eldiron" // { hostName = "eldiron.immae.eu"; documentRoot = ./www; extraConfig = '' DirectoryIndex index.htm ''; }) - (withSSL "eldiron" // { - listen = [ { ip = "*"; port = 443; } ]; + (withConf "eldiron" // { hostName = "db-1.immae.eu"; documentRoot = null; extraConfig = builtins.concatStringsSep "\n" [ mypkgs.adminer.apache.vhostConf ]; }) - (withSSL "eldiron" // { - listen = [ { ip = "*"; port = 443; } ]; + (withConf "eldiron" // { hostName = "tools.immae.eu"; documentRoot = null; extraConfig = builtins.concatStringsSep "\n" [ @@ -320,8 +401,7 @@ mypkgs.ympd.apache.vhostConf ]; }) - (withSSL "eldiron" // { - listen = [ { ip = "*"; port = 443; } ]; + (withConf "eldiron" // { hostName = "connexionswing.immae.eu"; serverAliases = [ "sandetludo.immae.eu" ]; documentRoot = mypkgs.connexionswing_dev.webRoot; @@ -329,16 +409,44 @@ mypkgs.connexionswing_dev.apache.vhostConf ]; }) - (withSSL "eldiron" // { - listen = [ { ip = "*"; port = 443; } ]; + (withConf "eldiron" // { + hostName = "ludivine.immae.eu"; + documentRoot = mypkgs.ludivinecassal_dev.webRoot; + extraConfig = builtins.concatStringsSep "\n" [ + mypkgs.ludivinecassal_dev.apache.vhostConf + ]; + }) + (withConf "ludivinecassal" // { + hostName = "ludivinecassal.com"; + serverAliases = [ "www.ludivinecassal.com" ]; + documentRoot = mypkgs.ludivinecassal_prod.webRoot; + extraConfig = builtins.concatStringsSep "\n" [ + mypkgs.ludivinecassal_prod.apache.vhostConf + ]; + }) + (withConf "eldiron" // { + hostName = "dev.aten.pro"; + documentRoot = mypkgs.aten_dev.webRoot; + extraConfig = builtins.concatStringsSep "\n" [ + mypkgs.aten_dev.apache.vhostConf + ]; + }) + (withConf "aten" // { + hostName = "aten.pro"; + serverAliases = [ "www.aten.pro" ]; + documentRoot = mypkgs.aten_prod.webRoot; + extraConfig = builtins.concatStringsSep "\n" [ + mypkgs.aten_prod.apache.vhostConf + ]; + }) + (withConf "eldiron" // { hostName = "cloud.immae.eu"; documentRoot = mypkgs.nextcloud.webRoot; extraConfig = builtins.concatStringsSep "\n" [ mypkgs.nextcloud.apache.vhostConf ]; }) - (withSSL "eldiron" // { - listen = [ { ip = "*"; port = 443; } ]; + (withConf "eldiron" // { hostName = "git.immae.eu"; documentRoot = mypkgs.git.web.webRoot; extraConfig = builtins.concatStringsSep "\n" [ @@ -355,6 +463,7 @@ hostName = "redirectSSL"; serverAliases = [ "*" ]; enableSSL = false; + logFormat = "combinedVhost"; documentRoot = "/var/lib/acme/acme-challenge"; extraConfig = '' RewriteEngine on @@ -370,7 +479,7 @@ security.pam.services = let pam_ldap = pkgs.pam_ldap; - pam_ldap_mysql = assert mylibs.checkEnv "NIXOPS_MYSQL_PAM_PASSWORD"; + pam_ldap_mysql = assert checkEnv "NIXOPS_MYSQL_PAM_PASSWORD"; pkgs.writeText "mysql.conf" '' host ldap.immae.eu base dc=immae,dc=eu @@ -444,5 +553,14 @@ #host all all all pam ''; }; + + services.cron = { + enable = true; + systemCronJobs = let + stats = domain: conf: "${pkgs.gnused}/bin/sed -n '/\\['$(LC_ALL=C ${pkgs.coreutils}/bin/date -d yesterday +'%d\\/%b\\/%Y')'/ p' /var/log/httpd/access_log-${domain} | ${pkgs.goaccess}/bin/goaccess -o /var/lib/goaccess/${domain}/index.html -p ${conf}"; + in [ + "5 0 * * * root ${stats "aten.pro" ./packages/aten_goaccess.conf}" + ]; + }; }; }