-
Notifications
You must be signed in to change notification settings - Fork 26
/
default.nix
53 lines (50 loc) · 1.52 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{ config, lib, mkUniqueUser, mkUniqueGroup, ... }:
{
options = {
root = lib.mkOption {
type = lib.types.path;
default = "${config.stateDir}/www";
example = /var/www/whatever;
description = "The directory where the static webserver looks for documents to serve.";
};
};
config = lib.mkMerge [
(lib.mkIf (config.root == "${config.stateDir}/www") {
directories.www = {
owner = mkUniqueUser config.webserver.user;
group = mkUniqueGroup config.webserver.group;
instance.before = [ "webserver-init.service" "instance-init.target" ];
# XXX: Make DRY with the one in static-darkhttpd!
postCreate = ''
cat > index.html <<EOF
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Nothing here yet?</title>
</head>
<body>
<h1>Nothing here yet?</h1>
<p>You can place files into
<code>${config.stateDir}/www</code>.</p>
</body>
</html>
EOF
'';
};
})
{ webserver.variant = "nginx";
webserver.nginx.extraConfig = ''
index index.html;
root ${toString config.root};
'';
tests.wanted = [ ./test.nix ];
}
];
meta = {
description = "Using nginx for static file serving (no CGI)";
maintainers = with lib.maintainers; [ qknight ];
license = lib.licenses.bsd2;
homepage = https://github.com/nixcloud/nixcloud-webservices;
};
}