]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/emilia/moodle.nix
Refactor websites
[perso/Immae/Config/Nix.git] / modules / private / websites / emilia / moodle.nix
1 { lib, pkgs, config, ... }:
2 let
3 cfg = config.myServices.websites.emilia.moodle;
4 env = config.myEnv.websites.emilia;
5 varDir = "/var/lib/emilia_moodle";
6 siteDir = ./moodle;
7 webappName = "emilia_moodle";
8 webappdir = config.services.websites.webappDirsPaths.emilia_moodle;
9 # php_admin_value[upload_max_filesize] = 50000000
10 # php_admin_value[post_max_size] = 50000000
11 configFile = ''
12 <?php // Moodle configuration file
13
14 unset($CFG);
15 global $CFG;
16 $CFG = new stdClass();
17
18 $CFG->dbtype = 'pgsql';
19 $CFG->dblibrary = 'native';
20 $CFG->dbhost = '${env.postgresql.host}';
21 $CFG->dbname = '${env.postgresql.database}';
22 $CFG->dbuser = '${env.postgresql.user}';
23 $CFG->dbpass = '${env.postgresql.password}';
24 $CFG->prefix = 'mdl_';
25 $CFG->dboptions = array (
26 'dbpersist' => 0,
27 'dbport' => '${env.postgreesql.port}',
28 'dbsocket' => '${env.postgresql.password}',
29 );
30
31 $CFG->wwwroot = 'https://www.saison-photo.org';
32 $CFG->dataroot = '${varDir}';
33 $CFG->admin = 'admin';
34
35 $CFG->directorypermissions = 02777;
36
37 require_once(__DIR__ . '/lib/setup.php');
38
39 // There is no php closing tag in this file,
40 // it is intentional because it prevents trailing whitespace problems!
41 '';
42 apacheUser = config.services.httpd.Prod.user;
43 apacheGroup = config.services.httpd.Prod.group;
44 in {
45 options.myServices.websites.emilia.moodle.enable = lib.mkEnableOption "enable Emilia's website";
46
47 config = lib.mkIf cfg.enable {
48 services.duplyBackup.profiles.emilia_moodle.rootDir = varDir;
49 system.activationScripts.emilia_moodle = ''
50 install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d ${varDir}
51 '';
52 services.websites.webappDirs.emilia_moodle = siteDir;
53 services.websites.env.production.vhostConfs.emilia_moodle = {
54 certName = "emilia";
55 certMainHost = "saison-photo.org";
56 hosts = [ "saison-photo.org" "www.saison-photo.org" ];
57 root = webappdir;
58 extraConfig = [
59 ''
60 <Directory ${webappdir}>
61 DirectoryIndex pause.html
62 Options Indexes FollowSymLinks MultiViews Includes
63 Require all granted
64 </Directory>
65 ''
66 ];
67 };
68 };
69 }