aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-05-11 10:23:33 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-05-11 10:23:33 +0200
commit9eae2b47b7b315b05a0e010f3003bd875685e260 (patch)
tree43c9cfeb2db393f64743daa4ec87e0fe78ab772e
parentb7ee93fcdee2509cd4c0caec2c5c59ccff5bab2c (diff)
downloadNix-9eae2b47b7b315b05a0e010f3003bd875685e260.tar.gz
Nix-9eae2b47b7b315b05a0e010f3003bd875685e260.tar.zst
Nix-9eae2b47b7b315b05a0e010f3003bd875685e260.zip
Move webstats outside of nixops
-rw-r--r--modules/default.nix1
-rw-r--r--modules/webapps/webstats/default.nix (renamed from nixops/modules/websites/commons/stats.nix)55
-rw-r--r--modules/webapps/webstats/goaccess.conf (renamed from nixops/modules/websites/commons/goaccess.conf)0
-rw-r--r--nixops/modules/websites/aten/default.nix9
-rw-r--r--nixops/modules/websites/chloe/default.nix9
-rw-r--r--nixops/modules/websites/connexionswing/default.nix9
-rw-r--r--nixops/modules/websites/default.nix6
-rw-r--r--nixops/modules/websites/ftp/denisejerome.nix9
-rw-r--r--nixops/modules/websites/ftp/immae.nix9
-rw-r--r--nixops/modules/websites/ftp/jerome.nix9
-rw-r--r--nixops/modules/websites/ftp/leila.nix7
-rw-r--r--nixops/modules/websites/ftp/nassime.nix9
-rw-r--r--nixops/modules/websites/ftp/release.nix9
-rw-r--r--nixops/modules/websites/ludivine/default.nix5
-rw-r--r--nixops/modules/websites/piedsjaloux/default.nix9
15 files changed, 50 insertions, 105 deletions
diff --git a/modules/default.nix b/modules/default.nix
index c920a51..2c993c5 100644
--- a/modules/default.nix
+++ b/modules/default.nix
@@ -2,6 +2,7 @@
2 myids = ./myids.nix; 2 myids = ./myids.nix;
3 secrets = ./secrets.nix; 3 secrets = ./secrets.nix;
4 4
5 webstats = ./webapps/webstats;
5 diaspora = ./webapps/diaspora.nix; 6 diaspora = ./webapps/diaspora.nix;
6 etherpad-lite = ./webapps/etherpad-lite.nix; 7 etherpad-lite = ./webapps/etherpad-lite.nix;
7 mastodon = ./webapps/mastodon.nix; 8 mastodon = ./webapps/mastodon.nix;
diff --git a/nixops/modules/websites/commons/stats.nix b/modules/webapps/webstats/default.nix
index 73595f1..f4916bd 100644
--- a/nixops/modules/websites/commons/stats.nix
+++ b/modules/webapps/webstats/default.nix
@@ -1,27 +1,42 @@
1{ lib, pkgs, config, mylibs, ... }: 1{ lib, pkgs, config, mylibs, ... }:
2let 2let
3 cfg = config.services.myWebsites.commons.stats; 3 name = "goaccess";
4 cfg = config.services.webstats;
4in { 5in {
5 options = { 6 options.services.webstats = {
6 services.myWebsites.commons.stats = { 7 dataDir = lib.mkOption {
7 enable = lib.mkEnableOption "enable statistics"; 8 type = lib.types.path;
8 sites = lib.mkOption { 9 default = "/var/lib/${name}";
9 type = lib.types.listOf (lib.types.submodule { 10 description = ''
10 options = { 11 The directory where Goaccess stores its data.
11 conf = lib.mkOption { 12 '';
12 type = lib.types.nullOr lib.types.path; 13 };
13 default = null; 14 sites = lib.mkOption {
14 }; 15 type = lib.types.listOf (lib.types.submodule {
15 name = lib.mkOption { type = lib.types.string; }; 16 options = {
17 conf = lib.mkOption {
18 type = lib.types.nullOr lib.types.path;
19 default = null;
20 description = ''
21 use custom goaccess configuration file instead of the
22 default one.
23 '';
24 };
25 name = lib.mkOption {
26 type = lib.types.string;
27 description = ''
28 Domain name. Corresponds to the Apache file name and the
29 folder name in which the state will be saved.
30 '';
16 }; 31 };
17 }); 32 };
18 default = []; 33 });
19 description = "Sites to generate stats"; 34 default = [];
20 }; 35 description = "Sites to generate stats";
21 }; 36 };
22 }; 37 };
23 38
24 config = lib.mkIf cfg.enable { 39 config = lib.mkIf (builtins.length cfg.sites > 0) {
25 users.users.root.packages = [ 40 users.users.root.packages = [
26 pkgs.goaccess 41 pkgs.goaccess
27 ]; 42 ];
@@ -32,7 +47,7 @@ in {
32 stats = domain: conf: let 47 stats = domain: conf: let
33 config = if builtins.isNull conf 48 config = if builtins.isNull conf
34 then pkgs.runCommand "goaccess.conf" { 49 then pkgs.runCommand "goaccess.conf" {
35 dbPath = "/var/lib/goaccess/${domain}"; 50 dbPath = "${cfg.dataDir}/${domain}";
36 } "substituteAll ${./goaccess.conf} $out" 51 } "substituteAll ${./goaccess.conf} $out"
37 else conf; 52 else conf;
38 d = pkgs.writeScriptBin "stats-${domain}" '' 53 d = pkgs.writeScriptBin "stats-${domain}" ''
@@ -47,7 +62,7 @@ in {
47 for i in /var/log/httpd/access_log-${domain}*.gz; do 62 for i in /var/log/httpd/access_log-${domain}*.gz; do
48 zcat "$i" | sed -n "/\\[$date_regex/ p" >> $TMPFILE 63 zcat "$i" | sed -n "/\\[$date_regex/ p" >> $TMPFILE
49 done 64 done
50 ${pkgs.goaccess}/bin/goaccess $TMPFILE --no-progress -o /var/lib/goaccess/${domain}/index.html -p ${config} 65 ${pkgs.goaccess}/bin/goaccess $TMPFILE --no-progress -o ${cfg.dataDir}/${domain}/index.html -p ${config}
51 ''; 66 '';
52 in "${d}/bin/stats-${domain}"; 67 in "${d}/bin/stats-${domain}";
53 allStats = sites: pkgs.writeScript "stats" '' 68 allStats = sites: pkgs.writeScript "stats" ''
@@ -64,6 +79,6 @@ in {
64 system.activationScripts.goaccess = '' 79 system.activationScripts.goaccess = ''
65 mkdir -p /var/lib/goaccess 80 mkdir -p /var/lib/goaccess
66 '' + 81 '' +
67 builtins.concatStringsSep "\n" (map (v: "mkdir -p /var/lib/goaccess/${v.name}") cfg.sites); 82 builtins.concatStringsSep "\n" (map (v: "mkdir -p ${cfg.dataDir}/${v.name}") cfg.sites);
68 }; 83 };
69} 84}
diff --git a/nixops/modules/websites/commons/goaccess.conf b/modules/webapps/webstats/goaccess.conf
index 4918988..4918988 100644
--- a/nixops/modules/websites/commons/goaccess.conf
+++ b/modules/webapps/webstats/goaccess.conf
diff --git a/nixops/modules/websites/aten/default.nix b/nixops/modules/websites/aten/default.nix
index 5dff008..fd3f7cc 100644
--- a/nixops/modules/websites/aten/default.nix
+++ b/nixops/modules/websites/aten/default.nix
@@ -19,17 +19,10 @@ in {
19 }; 19 };
20 }; 20 };
21 21
22 imports = [
23 ../commons/stats.nix
24 ];
25
26 config = lib.mkMerge [ 22 config = lib.mkMerge [
27 (lib.mkIf cfg.production.enable { 23 (lib.mkIf cfg.production.enable {
28 secrets.keys = aten_prod.keys; 24 secrets.keys = aten_prod.keys;
29 services.myWebsites.commons.stats.enable = true; 25 services.webstats.sites = [ { name = "aten.pro"; } ];
30 services.myWebsites.commons.stats.sites = [
31 { name = "aten.pro"; }
32 ];
33 26
34 security.acme.certs."aten" = config.services.myCertificates.certConfig // { 27 security.acme.certs."aten" = config.services.myCertificates.certConfig // {
35 domain = "aten.pro"; 28 domain = "aten.pro";
diff --git a/nixops/modules/websites/chloe/default.nix b/nixops/modules/websites/chloe/default.nix
index 8980077..a542d70 100644
--- a/nixops/modules/websites/chloe/default.nix
+++ b/nixops/modules/websites/chloe/default.nix
@@ -19,17 +19,10 @@ in {
19 }; 19 };
20 }; 20 };
21 21
22 imports = [
23 ../commons/stats.nix
24 ];
25
26 config = lib.mkMerge [ 22 config = lib.mkMerge [
27 (lib.mkIf cfg.production.enable { 23 (lib.mkIf cfg.production.enable {
28 secrets.keys = chloe_prod.keys; 24 secrets.keys = chloe_prod.keys;
29 services.myWebsites.commons.stats.enable = true; 25 services.webstats.sites = [ { name = "osteopathe-cc.fr"; } ];
30 services.myWebsites.commons.stats.sites = [
31 { name = "osteopathe-cc.fr"; }
32 ];
33 26
34 security.acme.certs."chloe" = config.services.myCertificates.certConfig // { 27 security.acme.certs."chloe" = config.services.myCertificates.certConfig // {
35 domain = "osteopathe-cc.fr"; 28 domain = "osteopathe-cc.fr";
diff --git a/nixops/modules/websites/connexionswing/default.nix b/nixops/modules/websites/connexionswing/default.nix
index 37426dd..773c8de 100644
--- a/nixops/modules/websites/connexionswing/default.nix
+++ b/nixops/modules/websites/connexionswing/default.nix
@@ -19,17 +19,10 @@ in {
19 }; 19 };
20 }; 20 };
21 21
22 imports = [
23 ../commons/stats.nix
24 ];
25
26 config = lib.mkMerge [ 22 config = lib.mkMerge [
27 (lib.mkIf cfg.production.enable { 23 (lib.mkIf cfg.production.enable {
28 secrets.keys = connexionswing_prod.keys; 24 secrets.keys = connexionswing_prod.keys;
29 services.myWebsites.commons.stats.enable = true; 25 services.webstats.sites = [ { name = "connexionswing.com"; } ];
30 services.myWebsites.commons.stats.sites = [
31 { name = "connexionswing.com"; }
32 ];
33 26
34 security.acme.certs."connexionswing" = config.services.myCertificates.certConfig // { 27 security.acme.certs."connexionswing" = config.services.myCertificates.certConfig // {
35 domain = "connexionswing.com"; 28 domain = "connexionswing.com";
diff --git a/nixops/modules/websites/default.nix b/nixops/modules/websites/default.nix
index ceef1e1..79cd1a1 100644
--- a/nixops/modules/websites/default.nix
+++ b/nixops/modules/websites/default.nix
@@ -260,13 +260,13 @@ in
260 stats = { 260 stats = {
261 extraConfig = '' 261 extraConfig = ''
262 <Macro Stats %{domain}> 262 <Macro Stats %{domain}>
263 Alias /awstats /var/lib/goaccess/%{domain} 263 Alias /webstats ${config.services.webstats.dataDir}/%{domain}
264 <Directory /var/lib/goaccess/%{domain}> 264 <Directory ${config.services.webstats.dataDir}/%{domain}>
265 DirectoryIndex index.html 265 DirectoryIndex index.html
266 AllowOverride None 266 AllowOverride None
267 Require all granted 267 Require all granted
268 </Directory> 268 </Directory>
269 <Location /awstats> 269 <Location /webstats>
270 Use LDAPConnect 270 Use LDAPConnect
271 Require ldap-group cn=%{domain},ou=stats,cn=httpd,ou=services,dc=immae,dc=eu 271 Require ldap-group cn=%{domain},ou=stats,cn=httpd,ou=services,dc=immae,dc=eu
272 </Location> 272 </Location>
diff --git a/nixops/modules/websites/ftp/denisejerome.nix b/nixops/modules/websites/ftp/denisejerome.nix
index f39e5c2..4069b46 100644
--- a/nixops/modules/websites/ftp/denisejerome.nix
+++ b/nixops/modules/websites/ftp/denisejerome.nix
@@ -10,15 +10,8 @@ in {
10 }; 10 };
11 }; 11 };
12 12
13 imports = [
14 ../commons/stats.nix
15 ];
16
17 config = lib.mkIf cfg.production.enable { 13 config = lib.mkIf cfg.production.enable {
18 services.myWebsites.commons.stats.enable = true; 14 services.webstats.sites = [ { name = "denisejerome.piedsjaloux.fr"; } ];
19 services.myWebsites.commons.stats.sites = [
20 { name = "denisejerome.piedsjaloux.fr"; }
21 ];
22 15
23 security.acme.certs."denisejerome" = config.services.myCertificates.certConfig // { 16 security.acme.certs."denisejerome" = config.services.myCertificates.certConfig // {
24 domain = "denisejerome.piedsjaloux.fr"; 17 domain = "denisejerome.piedsjaloux.fr";
diff --git a/nixops/modules/websites/ftp/immae.nix b/nixops/modules/websites/ftp/immae.nix
index 2ecca1f..d4e6d39 100644
--- a/nixops/modules/websites/ftp/immae.nix
+++ b/nixops/modules/websites/ftp/immae.nix
@@ -10,15 +10,8 @@ in {
10 }; 10 };
11 }; 11 };
12 12
13 imports = [
14 ../commons/stats.nix
15 ];
16
17 config = lib.mkIf cfg.production.enable { 13 config = lib.mkIf cfg.production.enable {
18 services.myWebsites.commons.stats.enable = true; 14 services.webstats.sites = [ { name = "www.immae.eu"; } ];
19 services.myWebsites.commons.stats.sites = [
20 { name = "www.immae.eu"; }
21 ];
22 15
23 security.acme.certs."eldiron".extraDomains."www.immae.eu" = null; 16 security.acme.certs."eldiron".extraDomains."www.immae.eu" = null;
24 17
diff --git a/nixops/modules/websites/ftp/jerome.nix b/nixops/modules/websites/ftp/jerome.nix
index e04d640..60e4dfb 100644
--- a/nixops/modules/websites/ftp/jerome.nix
+++ b/nixops/modules/websites/ftp/jerome.nix
@@ -11,15 +11,8 @@ in {
11 }; 11 };
12 }; 12 };
13 13
14 imports = [
15 ../commons/stats.nix
16 ];
17
18 config = lib.mkIf cfg.production.enable { 14 config = lib.mkIf cfg.production.enable {
19 services.myWebsites.commons.stats.enable = true; 15 services.webstats.sites = [ { name = "naturaloutil.immae.eu"; } ];
20 services.myWebsites.commons.stats.sites = [
21 { name = "naturaloutil.immae.eu"; }
22 ];
23 16
24 security.acme.certs."ftp".extraDomains."naturaloutil.immae.eu" = null; 17 security.acme.certs."ftp".extraDomains."naturaloutil.immae.eu" = null;
25 security.acme.certs."naturaloutil" = config.services.myCertificates.certConfig // { 18 security.acme.certs."naturaloutil" = config.services.myCertificates.certConfig // {
diff --git a/nixops/modules/websites/ftp/leila.nix b/nixops/modules/websites/ftp/leila.nix
index d5c27fa..c5c27b1 100644
--- a/nixops/modules/websites/ftp/leila.nix
+++ b/nixops/modules/websites/ftp/leila.nix
@@ -9,10 +9,6 @@ in {
9 }; 9 };
10 }; 10 };
11 11
12 imports = [
13 ../commons/stats.nix
14 ];
15
16 config = (lib.mkIf cfg.production.enable { 12 config = (lib.mkIf cfg.production.enable {
17 security.acme.certs."leila" = config.services.myCertificates.certConfig // { 13 security.acme.certs."leila" = config.services.myCertificates.certConfig // {
18 domain = "leila.bouya.org"; 14 domain = "leila.bouya.org";
@@ -37,8 +33,7 @@ in {
37 php_admin_value[open_basedir] = "${varDir}:/tmp" 33 php_admin_value[open_basedir] = "${varDir}:/tmp"
38 ''; 34 '';
39 35
40 services.myWebsites.commons.stats.enable = true; 36 services.webstats.sites = [
41 services.myWebsites.commons.stats.sites = [
42 { name = "leila.bouya.org"; } 37 { name = "leila.bouya.org"; }
43 { name = "chorale.leila.bouya.org"; } 38 { name = "chorale.leila.bouya.org"; }
44 ]; 39 ];
diff --git a/nixops/modules/websites/ftp/nassime.nix b/nixops/modules/websites/ftp/nassime.nix
index d7ced7e..f295045 100644
--- a/nixops/modules/websites/ftp/nassime.nix
+++ b/nixops/modules/websites/ftp/nassime.nix
@@ -10,15 +10,8 @@ in {
10 }; 10 };
11 }; 11 };
12 12
13 imports = [
14 ../commons/stats.nix
15 ];
16
17 config = lib.mkIf cfg.production.enable { 13 config = lib.mkIf cfg.production.enable {
18 services.myWebsites.commons.stats.enable = true; 14 services.webstats.sites = [ { name = "nassime.bouya.org"; } ];
19 services.myWebsites.commons.stats.sites = [
20 { name = "nassime.bouya.org"; }
21 ];
22 15
23 security.acme.certs."ftp".extraDomains."nassime.bouya.org" = null; 16 security.acme.certs."ftp".extraDomains."nassime.bouya.org" = null;
24 security.acme.certs."nassime" = config.services.myCertificates.certConfig // { 17 security.acme.certs."nassime" = config.services.myCertificates.certConfig // {
diff --git a/nixops/modules/websites/ftp/release.nix b/nixops/modules/websites/ftp/release.nix
index 2050a6c..896691b 100644
--- a/nixops/modules/websites/ftp/release.nix
+++ b/nixops/modules/websites/ftp/release.nix
@@ -10,15 +10,8 @@ in {
10 }; 10 };
11 }; 11 };
12 12
13 imports = [
14 ../commons/stats.nix
15 ];
16
17 config = lib.mkIf cfg.production.enable { 13 config = lib.mkIf cfg.production.enable {
18 services.myWebsites.commons.stats.enable = true; 14 services.webstats.sites = [ { name = "release.immae.eu"; } ];
19 services.myWebsites.commons.stats.sites = [
20 { name = "release.immae.eu"; }
21 ];
22 15
23 security.acme.certs."eldiron".extraDomains."release.immae.eu" = null; 16 security.acme.certs."eldiron".extraDomains."release.immae.eu" = null;
24 17
diff --git a/nixops/modules/websites/ludivine/default.nix b/nixops/modules/websites/ludivine/default.nix
index af18d71..2fcd94a 100644
--- a/nixops/modules/websites/ludivine/default.nix
+++ b/nixops/modules/websites/ludivine/default.nix
@@ -22,10 +22,7 @@ in {
22 config = lib.mkMerge [ 22 config = lib.mkMerge [
23 (lib.mkIf cfg.production.enable { 23 (lib.mkIf cfg.production.enable {
24 secrets.keys = ludivinecassal_prod.keys; 24 secrets.keys = ludivinecassal_prod.keys;
25 services.myWebsites.commons.stats.enable = true; 25 services.webstats.sites = [ { name = "ludivinecassal.com"; } ];
26 services.myWebsites.commons.stats.sites = [
27 { name = "ludivinecassal.com"; }
28 ];
29 26
30 security.acme.certs."ludivinecassal" = config.services.myCertificates.certConfig // { 27 security.acme.certs."ludivinecassal" = config.services.myCertificates.certConfig // {
31 domain = "ludivinecassal.com"; 28 domain = "ludivinecassal.com";
diff --git a/nixops/modules/websites/piedsjaloux/default.nix b/nixops/modules/websites/piedsjaloux/default.nix
index 1657914..9f9697d 100644
--- a/nixops/modules/websites/piedsjaloux/default.nix
+++ b/nixops/modules/websites/piedsjaloux/default.nix
@@ -19,17 +19,10 @@ in {
19 }; 19 };
20 }; 20 };
21 21
22 imports = [
23 ../commons/stats.nix
24 ];
25
26 config = lib.mkMerge [ 22 config = lib.mkMerge [
27 (lib.mkIf cfg.production.enable { 23 (lib.mkIf cfg.production.enable {
28 secrets.keys = piedsjaloux_prod.keys; 24 secrets.keys = piedsjaloux_prod.keys;
29 services.myWebsites.commons.stats.enable = true; 25 services.webstats.sites = [ { name = "piedsjaloux.fr"; } ];
30 services.myWebsites.commons.stats.sites = [
31 { name = "piedsjaloux.fr"; }
32 ];
33 26
34 security.acme.certs."piedsjaloux" = config.services.myCertificates.certConfig // { 27 security.acme.certs."piedsjaloux" = config.services.myCertificates.certConfig // {
35 domain = "piedsjaloux.fr"; 28 domain = "piedsjaloux.fr";