tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
moodle: Remove due to continued security issues.
Graham Christensen
9 years ago
7db1f727
afd59811
-198
1 changed file
expand all
collapse all
unified
split
nixos
modules
services
web-servers
apache-httpd
moodle.nix
-198
nixos/modules/services/web-servers/apache-httpd/moodle.nix
···
1
1
-
{ config, lib, pkgs, serverInfo, php, ... }:
2
2
-
3
3
-
with lib;
4
4
-
5
5
-
let
6
6
-
7
7
-
httpd = serverInfo.serverConfig.package;
8
8
-
9
9
-
version24 = !versionOlder httpd.version "2.4";
10
10
-
11
11
-
allGranted = if version24 then ''
12
12
-
Require all granted
13
13
-
'' else ''
14
14
-
Order allow,deny
15
15
-
Allow from all
16
16
-
'';
17
17
-
18
18
-
moodleConfig = pkgs.writeText "config.php"
19
19
-
''
20
20
-
<?php
21
21
-
unset($CFG);
22
22
-
global $CFG;
23
23
-
$CFG = new stdClass();
24
24
-
$CFG->dbtype = '${config.dbType}';
25
25
-
$CFG->dblibrary = 'native';
26
26
-
$CFG->dbhost = '${config.dbHost}';
27
27
-
$CFG->dbname = '${config.dbName}';
28
28
-
$CFG->dbuser = '${config.dbUser}';
29
29
-
$CFG->dbpass = '${config.dbPassword}';
30
30
-
$CFG->prefix = '${config.dbPrefix}';
31
31
-
$CFG->dboptions = array(
32
32
-
'dbpersist' => false,
33
33
-
'dbsocket' => false,
34
34
-
'dbport' => "${config.dbPort}",
35
35
-
);
36
36
-
$CFG->wwwroot = '${config.wwwRoot}';
37
37
-
$CFG->dataroot = '${config.dataRoot}';
38
38
-
$CFG->directorypermissions = 02777;
39
39
-
$CFG->admin = 'admin';
40
40
-
${optionalString (config.debug.noEmailEver == true) ''
41
41
-
$CFG->noemailever = true;
42
42
-
''}
43
43
-
44
44
-
${config.extraConfig}
45
45
-
require_once(dirname(__FILE__) . '/lib/setup.php'); // Do not edit
46
46
-
'';
47
47
-
# Unpack Moodle and put the config file in its root directory.
48
48
-
moodleRoot = pkgs.stdenv.mkDerivation rec {
49
49
-
name= "moodle-2.8.10";
50
50
-
51
51
-
src = pkgs.fetchurl {
52
52
-
url = "https://download.moodle.org/stable28/${name}.tgz";
53
53
-
sha256 = "0c3r5081ipcwc9s6shakllnrkd589y2ln5z5m1q09l4h6a7cy4z2";
54
54
-
};
55
55
-
56
56
-
buildPhase =
57
57
-
''
58
58
-
'';
59
59
-
60
60
-
installPhase =
61
61
-
''
62
62
-
mkdir -p $out
63
63
-
cp -r * $out
64
64
-
cp ${moodleConfig} $out/config.php
65
65
-
'';
66
66
-
# Marked as broken due to needing an update for security issues.
67
67
-
# See: https://github.com/NixOS/nixpkgs/issues/18856
68
68
-
meta.broken = true;
69
69
-
70
70
-
};
71
71
-
72
72
-
in
73
73
-
74
74
-
{
75
75
-
76
76
-
extraConfig =
77
77
-
''
78
78
-
# this should be config.urlPrefix instead of /
79
79
-
Alias / ${moodleRoot}/
80
80
-
<Directory ${moodleRoot}>
81
81
-
DirectoryIndex index.php
82
82
-
</Directory>
83
83
-
'';
84
84
-
85
85
-
documentRoot = moodleRoot; # TODO: fix this, should be config.urlPrefix
86
86
-
87
87
-
enablePHP = true;
88
88
-
89
89
-
options = {
90
90
-
91
91
-
id = mkOption {
92
92
-
default = "main";
93
93
-
description = ''
94
94
-
A unique identifier necessary to keep multiple Moodle server
95
95
-
instances on the same machine apart.
96
96
-
'';
97
97
-
};
98
98
-
99
99
-
dbType = mkOption {
100
100
-
default = "postgres";
101
101
-
example = "mysql";
102
102
-
description = "Database type.";
103
103
-
};
104
104
-
105
105
-
dbName = mkOption {
106
106
-
default = "moodle";
107
107
-
description = "Name of the database that holds the Moodle data.";
108
108
-
};
109
109
-
110
110
-
dbHost = mkOption {
111
111
-
default = "localhost";
112
112
-
example = "10.0.2.2";
113
113
-
description = ''
114
114
-
The location of the database server.
115
115
-
'';
116
116
-
};
117
117
-
118
118
-
dbPort = mkOption {
119
119
-
default = ""; # use the default port
120
120
-
example = "12345";
121
121
-
description = ''
122
122
-
The port that is used to connect to the database server.
123
123
-
'';
124
124
-
};
125
125
-
126
126
-
dbUser = mkOption {
127
127
-
default = "moodle";
128
128
-
description = "The user name for accessing the database.";
129
129
-
};
130
130
-
131
131
-
dbPassword = mkOption {
132
132
-
default = "";
133
133
-
example = "password";
134
134
-
description = ''
135
135
-
The password of the database user. Warning: this is stored in
136
136
-
cleartext in the Nix store!
137
137
-
'';
138
138
-
};
139
139
-
140
140
-
dbPrefix = mkOption {
141
141
-
default = "mdl_";
142
142
-
example = "my_other_mdl_";
143
143
-
description = ''
144
144
-
A prefix for each table, if multiple moodles should run in a single database.
145
145
-
'';
146
146
-
};
147
147
-
148
148
-
wwwRoot = mkOption {
149
149
-
type = types.string;
150
150
-
example = "http://my.machine.com/my-moodle";
151
151
-
description = ''
152
152
-
The full web address where moodle has been installed.
153
153
-
'';
154
154
-
};
155
155
-
156
156
-
dataRoot = mkOption {
157
157
-
default = "/var/lib/moodledata";
158
158
-
example = "/var/lib/moodledata";
159
159
-
description = ''
160
160
-
The data directory for moodle. Needs to be writable!
161
161
-
'';
162
162
-
type = types.path;
163
163
-
};
164
164
-
165
165
-
166
166
-
extraConfig = mkOption {
167
167
-
type = types.lines;
168
168
-
default = "";
169
169
-
example =
170
170
-
''
171
171
-
'';
172
172
-
description = ''
173
173
-
Any additional text to be appended to Moodle's
174
174
-
configuration file. This is a PHP script.
175
175
-
'';
176
176
-
};
177
177
-
178
178
-
debug = {
179
179
-
noEmailEver = mkOption {
180
180
-
default = false;
181
181
-
example = "true";
182
182
-
description = ''
183
183
-
Set this to true to prevent Moodle from ever sending any email.
184
184
-
'';
185
185
-
};
186
186
-
};
187
187
-
};
188
188
-
189
189
-
startupScript = pkgs.writeScript "moodle_startup.sh" ''
190
190
-
echo "Checking for existence of ${config.dataRoot}"
191
191
-
if [ ! -e "${config.dataRoot}" ]
192
192
-
then
193
193
-
mkdir -p "${config.dataRoot}"
194
194
-
chown ${serverInfo.serverConfig.user}.${serverInfo.serverConfig.group} "${config.dataRoot}"
195
195
-
fi
196
196
-
'';
197
197
-
198
198
-
}