diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-01-10 23:02:54 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-01-10 23:20:03 +0100 |
commit | 091ae73429b8853e6ab971bffaccd84bdd59f40d (patch) | |
tree | 17ba770ff2e30c6f2b3f2e87dc8937093bd39e30 /virtual/modules/websites/chloe | |
parent | ad915416a6886010139413f4fbc41ed827336aa2 (diff) | |
download | Nix-091ae73429b8853e6ab971bffaccd84bdd59f40d.tar.gz Nix-091ae73429b8853e6ab971bffaccd84bdd59f40d.tar.zst Nix-091ae73429b8853e6ab971bffaccd84bdd59f40d.zip |
Move packages fils to module
Diffstat (limited to 'virtual/modules/websites/chloe')
-rw-r--r-- | virtual/modules/websites/chloe/chloe.json | 14 | ||||
-rw-r--r-- | virtual/modules/websites/chloe/chloe.nix | 131 | ||||
-rw-r--r-- | virtual/modules/websites/chloe/chloe_config/chmod.php | 4 | ||||
-rw-r--r-- | virtual/modules/websites/chloe/chloe_config/connect.php | 6 | ||||
-rw-r--r-- | virtual/modules/websites/chloe/chloe_config/ldap.php | 9 | ||||
-rw-r--r-- | virtual/modules/websites/chloe/default.nix | 62 | ||||
-rw-r--r-- | virtual/modules/websites/chloe/goaccess.conf | 99 |
7 files changed, 325 insertions, 0 deletions
diff --git a/virtual/modules/websites/chloe/chloe.json b/virtual/modules/websites/chloe/chloe.json new file mode 100644 index 0000000..686d751 --- /dev/null +++ b/virtual/modules/websites/chloe/chloe.json | |||
@@ -0,0 +1,14 @@ | |||
1 | { | ||
2 | "tag": "96fc4eb-master", | ||
3 | "meta": { | ||
4 | "name": "chloe", | ||
5 | "url": "gitolite@git.immae.eu:perso/Immae/Sites/Chloe", | ||
6 | "branch": "master" | ||
7 | }, | ||
8 | "git": { | ||
9 | "url": "gitolite@git.immae.eu:perso/Immae/Sites/Chloe", | ||
10 | "rev": "96fc4eb0099a29b0f9a58fb4eaec4bf14ac65f0a", | ||
11 | "sha256": "0mf15j6z86j2smm2k360cmm5djhcjbs9949pznwi57kw97vkm1s3", | ||
12 | "fetchSubmodules": true | ||
13 | } | ||
14 | } | ||
diff --git a/virtual/modules/websites/chloe/chloe.nix b/virtual/modules/websites/chloe/chloe.nix new file mode 100644 index 0000000..126d8e7 --- /dev/null +++ b/virtual/modules/websites/chloe/chloe.nix | |||
@@ -0,0 +1,131 @@ | |||
1 | { stdenv, lib, checkEnv, fetchzip, fetchurl, fetchedGitPrivate, sassc }: | ||
2 | let | ||
3 | chloe = { environment ? "dev" }: rec { | ||
4 | varPrefix = "CHLOE"; | ||
5 | envName= lib.strings.toUpper environment; | ||
6 | phpFpm = rec { | ||
7 | socket = "/var/run/phpfpm/chloe-${environment}.sock"; | ||
8 | pool = | ||
9 | assert checkEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_PASSWORD"; | ||
10 | assert checkEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_USER"; | ||
11 | assert checkEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_DB"; | ||
12 | assert checkEnv "NIXOPS_${varPrefix}_${envName}_LDAP_DN"; | ||
13 | assert checkEnv "NIXOPS_${varPrefix}_${envName}_LDAP_PASSWORD"; | ||
14 | assert checkEnv "NIXOPS_${varPrefix}_${envName}_LDAP_SEARCH"; | ||
15 | '' | ||
16 | listen = ${socket} | ||
17 | user = ${apache.user} | ||
18 | group = ${apache.group} | ||
19 | listen.owner = ${apache.user} | ||
20 | listen.group = ${apache.group} | ||
21 | php_admin_value[upload_max_filesize] = 20M | ||
22 | php_admin_value[post_max_size] = 20M | ||
23 | ;php_admin_flag[log_errors] = on | ||
24 | php_admin_value[open_basedir] = "${../commons/spip/spip_mes_options.php}:${configDir}:${webRoot}:${varDir}:/tmp" | ||
25 | php_admin_value[session.save_path] = "${varDir}/phpSessions" | ||
26 | env[SPIP_CONFIG_DIR] = "${configDir}" | ||
27 | env[SPIP_VAR_DIR] = "${varDir}" | ||
28 | env[SPIP_SITE] = "chloe-${environment}" | ||
29 | env[SPIP_LDAP_BASE] = "dc=immae,dc=eu" | ||
30 | env[SPIP_LDAP_HOST] = "ldaps://ldap.immae.eu" | ||
31 | env[SPIP_LDAP_SEARCH_DN] = "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_LDAP_DN"}" | ||
32 | env[SPIP_LDAP_SEARCH_PW] = "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_LDAP_PASSWORD"}" | ||
33 | env[SPIP_LDAP_SEARCH] = "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_LDAP_SEARCH"}" | ||
34 | env[SPIP_MYSQL_HOST] = "db-1.immae.eu" | ||
35 | env[SPIP_MYSQL_DB] = "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_DB"}" | ||
36 | env[SPIP_MYSQL_USER] = "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_USER"}" | ||
37 | env[SPIP_MYSQL_PASSWORD] = "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_PASSWORD"}" | ||
38 | ${if environment == "dev" then '' | ||
39 | pm = ondemand | ||
40 | pm.max_children = 5 | ||
41 | pm.process_idle_timeout = 60 | ||
42 | '' else '' | ||
43 | pm = dynamic | ||
44 | pm.max_children = 20 | ||
45 | pm.start_servers = 2 | ||
46 | pm.min_spare_servers = 1 | ||
47 | pm.max_spare_servers = 3 | ||
48 | ''}''; | ||
49 | }; | ||
50 | apache = { | ||
51 | user = "wwwrun"; | ||
52 | group = "wwwrun"; | ||
53 | modules = [ "proxy_fcgi" ]; | ||
54 | vhostConf = '' | ||
55 | RewriteEngine On | ||
56 | ${if environment == "prod" then '' | ||
57 | RewriteRule ^/news.rss /spip.php?page=backend&id_rubrique=1 | ||
58 | '' else ""} | ||
59 | |||
60 | <FilesMatch "\.php$"> | ||
61 | SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" | ||
62 | </FilesMatch> | ||
63 | |||
64 | <Directory ${webRoot}> | ||
65 | DirectoryIndex index.php index.htm index.html | ||
66 | Options -Indexes +FollowSymLinks +MultiViews +Includes | ||
67 | Include ${webRoot}/htaccess.txt | ||
68 | |||
69 | AllowOverride AuthConfig FileInfo Limit | ||
70 | Require all granted | ||
71 | </Directory> | ||
72 | |||
73 | <DirectoryMatch "${webRoot}/squelettes"> | ||
74 | Require all denied | ||
75 | </DirectoryMatch> | ||
76 | |||
77 | <FilesMatch "(.htaccess|rewrite-rules|.gitignore)$"> | ||
78 | Require all denied | ||
79 | </FilesMatch> | ||
80 | |||
81 | ${if environment == "dev" then '' | ||
82 | <Location /> | ||
83 | Use LDAPConnect | ||
84 | Require ldap-group cn=chloe.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu | ||
85 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://osteopathe-cc.fr\"></html>" | ||
86 | </Location> | ||
87 | '' else '' | ||
88 | Use Stats osteopathe-cc.fr | ||
89 | ''} | ||
90 | ''; | ||
91 | }; | ||
92 | activationScript = { | ||
93 | deps = [ "wrappers" ]; | ||
94 | text = '' | ||
95 | install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} ${varDir}/IMG ${varDir}/tmp ${varDir}/local | ||
96 | install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions | ||
97 | ''; | ||
98 | }; | ||
99 | configDir = ./chloe_config; | ||
100 | varDir = "/var/lib/chloe_${environment}"; | ||
101 | siteDir = stdenv.mkDerivation (fetchedGitPrivate ./chloe.json // rec { | ||
102 | buildPhase = '' | ||
103 | make | ||
104 | ''; | ||
105 | installPhase = '' | ||
106 | cp -a . $out | ||
107 | ''; | ||
108 | buildInputs = [ sassc ]; | ||
109 | }); | ||
110 | webRoot = stdenv.mkDerivation rec { | ||
111 | name = "chloe-${environment}-spip-${version}"; | ||
112 | version = "3.2"; | ||
113 | src = fetchzip { | ||
114 | url = "http://files.spip.org/spip/stable/spip-${version}.zip"; | ||
115 | sha256 = "0cacpxs9nv61i3hzd3nbmplq4mp22s886llhacp3n4923jd6snx5"; | ||
116 | }; | ||
117 | paches = [ ../commons/spip/spip_ldap_patch.patch ]; | ||
118 | buildPhase = '' | ||
119 | rm -rf IMG local tmp config/remove.txt | ||
120 | ln -sf ${../commons/spip/spip_mes_options.php} config/mes_options.php | ||
121 | echo "Require all denied" > "config/.htaccess" | ||
122 | ln -sf ../../../../../${varDir}/{IMG,local} . | ||
123 | ''; | ||
124 | installPhase = '' | ||
125 | cp -a . $out | ||
126 | cp -a ${siteDir}/* $out | ||
127 | ''; | ||
128 | }; | ||
129 | }; | ||
130 | in | ||
131 | chloe | ||
diff --git a/virtual/modules/websites/chloe/chloe_config/chmod.php b/virtual/modules/websites/chloe/chloe_config/chmod.php new file mode 100644 index 0000000..aae16cd --- /dev/null +++ b/virtual/modules/websites/chloe/chloe_config/chmod.php | |||
@@ -0,0 +1,4 @@ | |||
1 | <?php | ||
2 | if (!defined("_ECRIRE_INC_VERSION")) return; | ||
3 | if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', 0777); | ||
4 | ?> \ No newline at end of file | ||
diff --git a/virtual/modules/websites/chloe/chloe_config/connect.php b/virtual/modules/websites/chloe/chloe_config/connect.php new file mode 100644 index 0000000..2e4439f --- /dev/null +++ b/virtual/modules/websites/chloe/chloe_config/connect.php | |||
@@ -0,0 +1,6 @@ | |||
1 | <?php | ||
2 | if (!defined("_ECRIRE_INC_VERSION")) return; | ||
3 | define('_MYSQL_SET_SQL_MODE',true); | ||
4 | $GLOBALS['spip_connect_version'] = 0.7; | ||
5 | spip_connect_db(getenv("SPIP_MYSQL_HOST"),'',getenv("SPIP_MYSQL_USER"),getenv("SPIP_MYSQL_PASSWORD"),getenv("SPIP_MYSQL_DB"),'mysql', 'spip','ldap.php'); | ||
6 | ?> | ||
diff --git a/virtual/modules/websites/chloe/chloe_config/ldap.php b/virtual/modules/websites/chloe/chloe_config/ldap.php new file mode 100644 index 0000000..825b7ed --- /dev/null +++ b/virtual/modules/websites/chloe/chloe_config/ldap.php | |||
@@ -0,0 +1,9 @@ | |||
1 | <?php | ||
2 | if (!defined("_ECRIRE_INC_VERSION")) return; | ||
3 | $GLOBALS['ldap_base'] = getenv("SPIP_LDAP_BASE"); | ||
4 | $GLOBALS['ldap_link'] = @ldap_connect(getenv("SPIP_LDAP_HOST")); | ||
5 | @ldap_set_option($GLOBALS['ldap_link'],LDAP_OPT_PROTOCOL_VERSION,'3'); | ||
6 | @ldap_bind($GLOBALS['ldap_link'],getenv("SPIP_LDAP_SEARCH_DN"), getenv("SPIP_LDAP_SEARCH_PW")); | ||
7 | $GLOBALS['ldap_champs'] = array('login' => array('sAMAccountName','uid','login','userid','cn','sn'),'nom' => 'cn','email' => 'mail','bio' => 'description',); | ||
8 | $GLOBALS['ldap_search'] = getenv("SPIP_LDAP_SEARCH"); | ||
9 | ?> | ||
diff --git a/virtual/modules/websites/chloe/default.nix b/virtual/modules/websites/chloe/default.nix new file mode 100644 index 0000000..72a9b6f --- /dev/null +++ b/virtual/modules/websites/chloe/default.nix | |||
@@ -0,0 +1,62 @@ | |||
1 | { lib, pkgs, config, mylibs, ... }: | ||
2 | let | ||
3 | chloe = pkgs.callPackage ./chloe.nix { inherit (mylibs) checkEnv fetchedGitPrivate; }; | ||
4 | chloe_dev = chloe { environment = "dev"; }; | ||
5 | chloe_prod = chloe { environment = "prod"; }; | ||
6 | |||
7 | cfg = config.services.myWebsites.Chloe; | ||
8 | in { | ||
9 | options.services.myWebsites.Chloe = { | ||
10 | production = { | ||
11 | enable = lib.mkEnableOption "enable Chloe's website in production"; | ||
12 | }; | ||
13 | integration = { | ||
14 | enable = lib.mkEnableOption "enable Chloe's website in integration"; | ||
15 | }; | ||
16 | }; | ||
17 | |||
18 | imports = [ | ||
19 | ../commons/stats.nix | ||
20 | ]; | ||
21 | |||
22 | config = lib.mkMerge [ | ||
23 | (lib.mkIf cfg.production.enable { | ||
24 | services.myWebsites.commons.stats.enable = true; | ||
25 | services.myWebsites.commons.stats.sites = [ | ||
26 | { | ||
27 | name = "osteopathe-cc.fr"; | ||
28 | conf = ./goaccess.conf; | ||
29 | } | ||
30 | ]; | ||
31 | |||
32 | security.acme.certs."chloe" = config.services.myCertificates.certConfig // { | ||
33 | domain = "osteopathe-cc.fr"; | ||
34 | extraDomains = { | ||
35 | "www.osteopathe-cc.fr" = null; | ||
36 | }; | ||
37 | }; | ||
38 | |||
39 | services.phpfpm.poolConfigs.chloe_prod = chloe_prod.phpFpm.pool; | ||
40 | system.activationScripts.chloe_prod = chloe_prod.activationScript; | ||
41 | services.myWebsites.production.modules = chloe_prod.apache.modules; | ||
42 | services.myWebsites.production.vhostConfs.chloe = { | ||
43 | certName = "chloe"; | ||
44 | hosts = ["osteopathe-cc.fr" "www.osteopathe-cc.fr" ]; | ||
45 | root = chloe_prod.webRoot; | ||
46 | extraConfig = [ chloe_prod.apache.vhostConf ]; | ||
47 | }; | ||
48 | }) | ||
49 | (lib.mkIf cfg.integration.enable { | ||
50 | security.acme.certs."eldiron".extraDomains."chloe.immae.eu" = null; | ||
51 | services.phpfpm.poolConfigs.chloe_dev = chloe_dev.phpFpm.pool; | ||
52 | system.activationScripts.chloe_dev = chloe_dev.activationScript; | ||
53 | services.myWebsites.integration.modules = chloe_dev.apache.modules; | ||
54 | services.myWebsites.integration.vhostConfs.chloe = { | ||
55 | certName = "eldiron"; | ||
56 | hosts = ["chloe.immae.eu" ]; | ||
57 | root = chloe_dev.webRoot; | ||
58 | extraConfig = [ chloe_dev.apache.vhostConf ]; | ||
59 | }; | ||
60 | }) | ||
61 | ]; | ||
62 | } | ||
diff --git a/virtual/modules/websites/chloe/goaccess.conf b/virtual/modules/websites/chloe/goaccess.conf new file mode 100644 index 0000000..89cff6d --- /dev/null +++ b/virtual/modules/websites/chloe/goaccess.conf | |||
@@ -0,0 +1,99 @@ | |||
1 | time-format %H:%M:%S | ||
2 | date-format %d/%b/%Y | ||
3 | |||
4 | #sur immae.eu | ||
5 | #log-format %v %h %^[%d:%t %^] "%r" %s %b "%R" "%u" $^ | ||
6 | |||
7 | log-format VCOMBINED | ||
8 | #= %v:%^ %h %^[%d:%t %^] "%r" %s %b "%R" "%u" | ||
9 | |||
10 | html-prefs {"theme":"bright","layout":"vertical"} | ||
11 | |||
12 | exclude-ip 188.165.209.148 | ||
13 | exclude-ip 178.33.252.96 | ||
14 | exclude-ip 2001:41d0:2:9c94::1 | ||
15 | exclude-ip 2001:41d0:2:9c94:: | ||
16 | exclude-ip 176.9.151.89 | ||
17 | exclude-ip 2a01:4f8:160:3445:: | ||
18 | exclude-ip 82.255.56.72 | ||
19 | |||
20 | no-query-string true | ||
21 | |||
22 | keep-db-files true | ||
23 | load-from-disk true | ||
24 | db-path /var/lib/goaccess/osteopathe-cc.fr | ||
25 | |||
26 | ignore-panel REFERRERS | ||
27 | ignore-panel KEYPHRASES | ||
28 | |||
29 | static-file .css | ||
30 | static-file .js | ||
31 | static-file .jpg | ||
32 | static-file .png | ||
33 | static-file .gif | ||
34 | static-file .ico | ||
35 | static-file .jpeg | ||
36 | static-file .pdf | ||
37 | static-file .csv | ||
38 | static-file .mpeg | ||
39 | static-file .mpg | ||
40 | static-file .swf | ||
41 | static-file .woff | ||
42 | static-file .woff2 | ||
43 | static-file .xls | ||
44 | static-file .xlsx | ||
45 | static-file .doc | ||
46 | static-file .docx | ||
47 | static-file .ppt | ||
48 | static-file .pptx | ||
49 | static-file .txt | ||
50 | static-file .zip | ||
51 | static-file .ogg | ||
52 | static-file .mp3 | ||
53 | static-file .mp4 | ||
54 | static-file .exe | ||
55 | static-file .iso | ||
56 | static-file .gz | ||
57 | static-file .rar | ||
58 | static-file .svg | ||
59 | static-file .bmp | ||
60 | static-file .tar | ||
61 | static-file .tgz | ||
62 | static-file .tiff | ||
63 | static-file .tif | ||
64 | static-file .ttf | ||
65 | static-file .flv | ||
66 | #static-file .less | ||
67 | #static-file .ac3 | ||
68 | #static-file .avi | ||
69 | #static-file .bz2 | ||
70 | #static-file .class | ||
71 | #static-file .cue | ||
72 | #static-file .dae | ||
73 | #static-file .dat | ||
74 | #static-file .dts | ||
75 | #static-file .ejs | ||
76 | #static-file .eot | ||
77 | #static-file .eps | ||
78 | #static-file .img | ||
79 | #static-file .jar | ||
80 | #static-file .map | ||
81 | #static-file .mid | ||
82 | #static-file .midi | ||
83 | #static-file .ogv | ||
84 | #static-file .webm | ||
85 | #static-file .mkv | ||
86 | #static-file .odp | ||
87 | #static-file .ods | ||
88 | #static-file .odt | ||
89 | #static-file .otf | ||
90 | #static-file .pict | ||
91 | #static-file .pls | ||
92 | #static-file .ps | ||
93 | #static-file .qt | ||
94 | #static-file .rm | ||
95 | #static-file .svgz | ||
96 | #static-file .wav | ||
97 | #static-file .webp | ||
98 | |||
99 | |||