aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-05-12 17:57:20 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-05-12 17:58:22 +0200
commit8f904d0d982684e8e66dfc5d9123712eb96bf16e (patch)
tree4574838fb67902680f41754d73af8f5d33ce35f6
parent9129f327844ca58af61a20582b04e35762c63e35 (diff)
downloadNix-8f904d0d982684e8e66dfc5d9123712eb96bf16e.tar.gz
Nix-8f904d0d982684e8e66dfc5d9123712eb96bf16e.tar.zst
Nix-8f904d0d982684e8e66dfc5d9123712eb96bf16e.zip
Refactor a bit httpd/webapps configuration:
- alias private to pkgs - move default apache vhost to pkgs
-rw-r--r--nixops/modules/websites/apache/per-server-options.nix188
-rw-r--r--nixops/modules/websites/aten/default.nix4
-rw-r--r--nixops/modules/websites/chloe/default.nix4
-rw-r--r--nixops/modules/websites/connexionswing/default.nix4
-rw-r--r--nixops/modules/websites/default.nix18
-rw-r--r--nixops/modules/websites/ludivine/default.nix4
-rw-r--r--nixops/modules/websites/piedsjaloux/default.nix4
-rw-r--r--nixops/modules/websites/tellesflorian/default.nix2
-rw-r--r--pkgs/default.nix2
-rw-r--r--pkgs/private/webapps/apache-default/default.nix21
-rw-r--r--pkgs/private/webapps/apache-default/www/googleb6d69446ff4ca3e5.html (renamed from nixops/www/googleb6d69446ff4ca3e5.html)0
-rw-r--r--pkgs/private/webapps/apache-default/www/index.htm (renamed from nixops/www/index.htm)0
-rw-r--r--pkgs/private/webapps/apache-default/www/maintenance_immae.html (renamed from nixops/www/maintenance_immae.html)0
-rw-r--r--pkgs/private/webapps/apache-default/www/nossl.html (renamed from nixops/www/nossl.html)0
-rw-r--r--pkgs/private/webapps/default.nix2
-rw-r--r--pkgs/webapps/apache-theme/default.nix8
-rw-r--r--pkgs/webapps/default.nix4
17 files changed, 44 insertions, 221 deletions
diff --git a/nixops/modules/websites/apache/per-server-options.nix b/nixops/modules/websites/apache/per-server-options.nix
deleted file mode 100644
index 4bbd041..0000000
--- a/nixops/modules/websites/apache/per-server-options.nix
+++ /dev/null
@@ -1,188 +0,0 @@
1# This file defines the options that can be used both for the Apache
2# main server configuration, and for the virtual hosts. (The latter
3# has additional options that affect the web server as a whole, like
4# the user/group to run under.)
5
6{ forMainServer, lib }:
7
8with lib;
9
10{
11
12 hostName = mkOption {
13 type = types.str;
14 default = "localhost";
15 description = "Canonical hostname for the server.";
16 };
17
18 serverAliases = mkOption {
19 type = types.listOf types.str;
20 default = [];
21 example = ["www.example.org" "www.example.org:8080" "example.org"];
22 description = ''
23 Additional names of virtual hosts served by this virtual host configuration.
24 '';
25 };
26
27 port = mkOption {
28 type = types.int;
29 default = 0;
30 description = ''
31 Port for the server. Option will be removed, use <option>listen</option> instead.
32 '';
33 };
34
35 listen = mkOption {
36 type = types.listOf (types.submodule (
37 {
38 options = {
39 port = mkOption {
40 type = types.int;
41 description = "port to listen on";
42 };
43 ip = mkOption {
44 type = types.string;
45 default = "*";
46 description = "Ip to listen on. 0.0.0.0 for ipv4 only, * for all.";
47 };
48 };
49 } ));
50 description = ''
51 List of { /* ip: "*"; */ port = 80;} to listen on
52 '';
53
54 default = [];
55 };
56
57 enableSSL = mkOption {
58 type = types.bool;
59 default = false;
60 description = "Whether to enable SSL (https) support.";
61 };
62
63 # Note: sslServerCert and sslServerKey can be left empty, but this
64 # only makes sense for virtual hosts (they will inherit from the
65 # main server).
66
67 sslServerCert = mkOption {
68 type = types.nullOr types.path;
69 default = null;
70 example = "/var/host.cert";
71 description = "Path to server SSL certificate.";
72 };
73
74 sslServerKey = mkOption {
75 type = types.path;
76 example = "/var/host.key";
77 description = "Path to server SSL certificate key.";
78 };
79
80 sslServerChain = mkOption {
81 type = types.nullOr types.path;
82 default = null;
83 example = "/var/ca.pem";
84 description = "Path to server SSL chain file.";
85 };
86
87 adminAddr = mkOption ({
88 type = types.nullOr types.str;
89 example = "admin@example.org";
90 description = "E-mail address of the server administrator.";
91 } // (if forMainServer then {} else {default = null;}));
92
93 documentRoot = mkOption {
94 type = types.nullOr types.path;
95 default = null;
96 example = "/data/webserver/docs";
97 description = ''
98 The path of Apache's document root directory. If left undefined,
99 an empty directory in the Nix store will be used as root.
100 '';
101 };
102
103 servedDirs = mkOption {
104 type = types.listOf types.attrs;
105 default = [];
106 example = [
107 { urlPath = "/nix";
108 dir = "/home/eelco/Dev/nix-homepage";
109 }
110 ];
111 description = ''
112 This option provides a simple way to serve static directories.
113 '';
114 };
115
116 servedFiles = mkOption {
117 type = types.listOf types.attrs;
118 default = [];
119 example = [
120 { urlPath = "/foo/bar.png";
121 file = "/home/eelco/some-file.png";
122 }
123 ];
124 description = ''
125 This option provides a simple way to serve individual, static files.
126 '';
127 };
128
129 extraConfig = mkOption {
130 type = types.lines;
131 default = "";
132 example = ''
133 <Directory /home>
134 Options FollowSymlinks
135 AllowOverride All
136 </Directory>
137 '';
138 description = ''
139 These lines go to httpd.conf verbatim. They will go after
140 directories and directory aliases defined by default.
141 '';
142 };
143
144 extraSubservices = mkOption {
145 type = types.listOf types.unspecified;
146 default = [];
147 description = "Extra subservices to enable in the webserver.";
148 };
149
150 enableUserDir = mkOption {
151 type = types.bool;
152 default = false;
153 description = ''
154 Whether to enable serving <filename>~/public_html</filename> as
155 <literal>/~<replaceable>username</replaceable></literal>.
156 '';
157 };
158
159 globalRedirect = mkOption {
160 type = types.nullOr types.str;
161 default = null;
162 example = http://newserver.example.org/;
163 description = ''
164 If set, all requests for this host are redirected permanently to
165 the given URL.
166 '';
167 };
168
169 logFormat = mkOption {
170 type = types.str;
171 default = "common";
172 example = "combined";
173 description = ''
174 Log format for Apache's log files. Possible values are: combined, common, referer, agent.
175 '';
176 };
177
178 robotsEntries = mkOption {
179 type = types.lines;
180 default = "";
181 example = "Disallow: /foo/";
182 description = ''
183 Specification of pages to be ignored by web crawlers. See <link
184 xlink:href='http://www.robotstxt.org/'/> for details.
185 '';
186 };
187
188}
diff --git a/nixops/modules/websites/aten/default.nix b/nixops/modules/websites/aten/default.nix
index 0b2ce69..70bb34b 100644
--- a/nixops/modules/websites/aten/default.nix
+++ b/nixops/modules/websites/aten/default.nix
@@ -1,11 +1,11 @@
1{ lib, pkgs, config, myconfig, ... }: 1{ lib, pkgs, config, myconfig, ... }:
2let 2let
3 aten_dev = pkgs.callPackage ./aten.nix { 3 aten_dev = pkgs.callPackage ./aten.nix {
4 inherit (pkgs.private.webapps) aten; 4 inherit (pkgs.webapps) aten;
5 config = myconfig.env.websites.aten.integration; 5 config = myconfig.env.websites.aten.integration;
6 }; 6 };
7 aten_prod = pkgs.callPackage ./aten.nix { 7 aten_prod = pkgs.callPackage ./aten.nix {
8 inherit (pkgs.private.webapps) aten; 8 inherit (pkgs.webapps) aten;
9 config = myconfig.env.websites.aten.production; 9 config = myconfig.env.websites.aten.production;
10 }; 10 };
11 11
diff --git a/nixops/modules/websites/chloe/default.nix b/nixops/modules/websites/chloe/default.nix
index ea984ae..ce67bed 100644
--- a/nixops/modules/websites/chloe/default.nix
+++ b/nixops/modules/websites/chloe/default.nix
@@ -1,11 +1,11 @@
1{ lib, pkgs, config, myconfig, ... }: 1{ lib, pkgs, config, myconfig, ... }:
2let 2let
3 chloe_dev = pkgs.callPackage ./chloe.nix { 3 chloe_dev = pkgs.callPackage ./chloe.nix {
4 inherit (pkgs.private.webapps) chloe; 4 inherit (pkgs.webapps) chloe;
5 config = myconfig.env.websites.chloe.integration; 5 config = myconfig.env.websites.chloe.integration;
6 }; 6 };
7 chloe_prod = pkgs.callPackage ./chloe.nix { 7 chloe_prod = pkgs.callPackage ./chloe.nix {
8 inherit (pkgs.private.webapps) chloe; 8 inherit (pkgs.webapps) chloe;
9 config = myconfig.env.websites.chloe.production; 9 config = myconfig.env.websites.chloe.production;
10 }; 10 };
11 11
diff --git a/nixops/modules/websites/connexionswing/default.nix b/nixops/modules/websites/connexionswing/default.nix
index e31a574..b19af7e 100644
--- a/nixops/modules/websites/connexionswing/default.nix
+++ b/nixops/modules/websites/connexionswing/default.nix
@@ -1,11 +1,11 @@
1{ lib, pkgs, config, myconfig, ... }: 1{ lib, pkgs, config, myconfig, ... }:
2let 2let
3 connexionswing_dev = pkgs.callPackage ./connexionswing.nix { 3 connexionswing_dev = pkgs.callPackage ./connexionswing.nix {
4 inherit (pkgs.private.webapps) connexionswing; 4 inherit (pkgs.webapps) connexionswing;
5 config = myconfig.env.websites.connexionswing.integration; 5 config = myconfig.env.websites.connexionswing.integration;
6 }; 6 };
7 connexionswing_prod = pkgs.callPackage ./connexionswing.nix { 7 connexionswing_prod = pkgs.callPackage ./connexionswing.nix {
8 inherit (pkgs.private.webapps) connexionswing; 8 inherit (pkgs.webapps) connexionswing;
9 config = myconfig.env.websites.connexionswing.production; 9 config = myconfig.env.websites.connexionswing.production;
10 }; 10 };
11 11
diff --git a/nixops/modules/websites/default.nix b/nixops/modules/websites/default.nix
index 891d917..8bbb344 100644
--- a/nixops/modules/websites/default.nix
+++ b/nixops/modules/websites/default.nix
@@ -288,21 +288,7 @@ in
288 ''; 288 '';
289 }; 289 };
290 global = { 290 global = {
291 extraConfig = '' 291 extraConfig = (pkgs.webapps.apache-default.override { inherit www_root;}).apacheConfig;
292 ErrorDocument 500 /maintenance_immae.html
293 ErrorDocument 501 /maintenance_immae.html
294 ErrorDocument 502 /maintenance_immae.html
295 ErrorDocument 503 /maintenance_immae.html
296 ErrorDocument 504 /maintenance_immae.html
297 Alias /maintenance_immae.html ${www_root}/maintenance_immae.html
298 ProxyPass /maintenance_immae.html !
299
300 AliasMatch "(.*)/googleb6d69446ff4ca3e5.html" ${www_root}/googleb6d69446ff4ca3e5.html
301 <Directory ${www_root}>
302 AllowOverride None
303 Require all granted
304 </Directory>
305 '';
306 }; 292 };
307 apaxy = { 293 apaxy = {
308 extraConfig = (pkgs.webapps.apache-theme.override { inherit theme_root; }).apacheConfig; 294 extraConfig = (pkgs.webapps.apache-theme.override { inherit theme_root; }).apacheConfig;
@@ -336,7 +322,7 @@ in
336 adminer = pkgs.callPackage ./commons/adminer.nix {}; 322 adminer = pkgs.callPackage ./commons/adminer.nix {};
337 in '' 323 in ''
338 mkdir -p $out/webapps 324 mkdir -p $out/webapps
339 ln -s ${../../www} $out/webapps/_www 325 ln -s ${pkgs.webapps.apache-default.www} $out/webapps/_www
340 ln -s ${pkgs.webapps.apache-theme.theme} $out/webapps/_theme 326 ln -s ${pkgs.webapps.apache-theme.theme} $out/webapps/_theme
341 ln -s ${adminer.webRoot} $out/webapps/${adminer.apache.webappName} 327 ln -s ${adminer.webRoot} $out/webapps/${adminer.apache.webappName}
342 ''; 328 '';
diff --git a/nixops/modules/websites/ludivine/default.nix b/nixops/modules/websites/ludivine/default.nix
index 69c5720..df75eff 100644
--- a/nixops/modules/websites/ludivine/default.nix
+++ b/nixops/modules/websites/ludivine/default.nix
@@ -1,11 +1,11 @@
1{ lib, pkgs, config, myconfig, ... }: 1{ lib, pkgs, config, myconfig, ... }:
2let 2let
3 ludivinecassal_dev = pkgs.callPackage ./ludivinecassal.nix { 3 ludivinecassal_dev = pkgs.callPackage ./ludivinecassal.nix {
4 inherit (pkgs.private.webapps) ludivinecassal; 4 inherit (pkgs.webapps) ludivinecassal;
5 config = myconfig.env.websites.ludivinecassal.integration; 5 config = myconfig.env.websites.ludivinecassal.integration;
6 }; 6 };
7 ludivinecassal_prod = pkgs.callPackage ./ludivinecassal.nix { 7 ludivinecassal_prod = pkgs.callPackage ./ludivinecassal.nix {
8 inherit (pkgs.private.webapps) ludivinecassal; 8 inherit (pkgs.webapps) ludivinecassal;
9 config = myconfig.env.websites.ludivinecassal.production; 9 config = myconfig.env.websites.ludivinecassal.production;
10 }; 10 };
11 11
diff --git a/nixops/modules/websites/piedsjaloux/default.nix b/nixops/modules/websites/piedsjaloux/default.nix
index 97f9557..10c1f6c 100644
--- a/nixops/modules/websites/piedsjaloux/default.nix
+++ b/nixops/modules/websites/piedsjaloux/default.nix
@@ -1,11 +1,11 @@
1{ lib, pkgs, config, myconfig, ... }: 1{ lib, pkgs, config, myconfig, ... }:
2let 2let
3 piedsjaloux_dev = pkgs.callPackage ./piedsjaloux.nix { 3 piedsjaloux_dev = pkgs.callPackage ./piedsjaloux.nix {
4 inherit (pkgs.private.webapps) piedsjaloux; 4 inherit (pkgs.webapps) piedsjaloux;
5 config = myconfig.env.websites.piedsjaloux.integration; 5 config = myconfig.env.websites.piedsjaloux.integration;
6 }; 6 };
7 piedsjaloux_prod = pkgs.callPackage ./piedsjaloux.nix { 7 piedsjaloux_prod = pkgs.callPackage ./piedsjaloux.nix {
8 inherit (pkgs.private.webapps) piedsjaloux; 8 inherit (pkgs.webapps) piedsjaloux;
9 config = myconfig.env.websites.piedsjaloux.production; 9 config = myconfig.env.websites.piedsjaloux.production;
10 }; 10 };
11 11
diff --git a/nixops/modules/websites/tellesflorian/default.nix b/nixops/modules/websites/tellesflorian/default.nix
index da4b5a6..93ee023 100644
--- a/nixops/modules/websites/tellesflorian/default.nix
+++ b/nixops/modules/websites/tellesflorian/default.nix
@@ -3,7 +3,7 @@ let
3 adminer = pkgs.callPackage ../commons/adminer.nix {}; 3 adminer = pkgs.callPackage ../commons/adminer.nix {};
4 4
5 tellesflorian_dev = pkgs.callPackage ./tellesflorian.nix { 5 tellesflorian_dev = pkgs.callPackage ./tellesflorian.nix {
6 inherit (pkgs.private.webapps) tellesflorian; 6 inherit (pkgs.webapps) tellesflorian;
7 config = myconfig.env.websites.tellesflorian.integration; 7 config = myconfig.env.websites.tellesflorian.integration;
8 }; 8 };
9 9
diff --git a/pkgs/default.nix b/pkgs/default.nix
index 26b32e1..8ea65a5 100644
--- a/pkgs/default.nix
+++ b/pkgs/default.nix
@@ -38,7 +38,7 @@ rec {
38 bitlbee-mastodon = callPackage ./bitlbee-mastodon {}; 38 bitlbee-mastodon = callPackage ./bitlbee-mastodon {};
39 39
40 composerEnv = callPackage ./composer-env {}; 40 composerEnv = callPackage ./composer-env {};
41 webapps = callPackage ./webapps { inherit mylibs composerEnv; }; 41 webapps = callPackage ./webapps { inherit mylibs composerEnv private; };
42 42
43 private = if builtins.pathExists (./. + "/private") 43 private = if builtins.pathExists (./. + "/private")
44 then import ./private { inherit pkgs; } 44 then import ./private { inherit pkgs; }
diff --git a/pkgs/private/webapps/apache-default/default.nix b/pkgs/private/webapps/apache-default/default.nix
new file mode 100644
index 0000000..92f558e
--- /dev/null
+++ b/pkgs/private/webapps/apache-default/default.nix
@@ -0,0 +1,21 @@
1{ www_root ? null }:
2rec {
3 www = ./www;
4 apacheConfig = let
5 www_root' = if isNull www_root then www else www_root;
6 in ''
7 ErrorDocument 500 /maintenance_immae.html
8 ErrorDocument 501 /maintenance_immae.html
9 ErrorDocument 502 /maintenance_immae.html
10 ErrorDocument 503 /maintenance_immae.html
11 ErrorDocument 504 /maintenance_immae.html
12 Alias /maintenance_immae.html ${www_root'}/maintenance_immae.html
13 ProxyPass /maintenance_immae.html !
14
15 AliasMatch "(.*)/googleb6d69446ff4ca3e5.html" ${www_root'}/googleb6d69446ff4ca3e5.html
16 <Directory ${www_root'}>
17 AllowOverride None
18 Require all granted
19 </Directory>
20 '';
21}
diff --git a/nixops/www/googleb6d69446ff4ca3e5.html b/pkgs/private/webapps/apache-default/www/googleb6d69446ff4ca3e5.html
index ff6dbf3..ff6dbf3 100644
--- a/nixops/www/googleb6d69446ff4ca3e5.html
+++ b/pkgs/private/webapps/apache-default/www/googleb6d69446ff4ca3e5.html
diff --git a/nixops/www/index.htm b/pkgs/private/webapps/apache-default/www/index.htm
index 0274251..0274251 100644
--- a/nixops/www/index.htm
+++ b/pkgs/private/webapps/apache-default/www/index.htm
diff --git a/nixops/www/maintenance_immae.html b/pkgs/private/webapps/apache-default/www/maintenance_immae.html
index 90f265f..90f265f 100644
--- a/nixops/www/maintenance_immae.html
+++ b/pkgs/private/webapps/apache-default/www/maintenance_immae.html
diff --git a/nixops/www/nossl.html b/pkgs/private/webapps/apache-default/www/nossl.html
index 4401a80..4401a80 100644
--- a/nixops/www/nossl.html
+++ b/pkgs/private/webapps/apache-default/www/nossl.html
diff --git a/pkgs/private/webapps/default.nix b/pkgs/private/webapps/default.nix
index 14fd544..e9aa13c 100644
--- a/pkgs/private/webapps/default.nix
+++ b/pkgs/private/webapps/default.nix
@@ -1,5 +1,7 @@
1{ callPackage, mylibs, composerEnv, lib, spip }: 1{ callPackage, mylibs, composerEnv, lib, spip }:
2rec { 2rec {
3 apache-default = callPackage ./apache-default {};
4
3 aten = callPackage ./aten { inherit composerEnv mylibs; }; 5 aten = callPackage ./aten { inherit composerEnv mylibs; };
4 chloe = callPackage ./chloe { inherit mylibs spip; }; 6 chloe = callPackage ./chloe { inherit mylibs spip; };
5 connexionswing = callPackage ./connexionswing { inherit composerEnv mylibs;}; 7 connexionswing = callPackage ./connexionswing { inherit composerEnv mylibs;};
diff --git a/pkgs/webapps/apache-theme/default.nix b/pkgs/webapps/apache-theme/default.nix
index b679afe..4b5755a 100644
--- a/pkgs/webapps/apache-theme/default.nix
+++ b/pkgs/webapps/apache-theme/default.nix
@@ -1,10 +1,12 @@
1{ theme_root ? null }: 1{ theme_root ? null }:
2rec { 2rec {
3 theme = ./theme; 3 theme = ./theme;
4 apacheConfig = '' 4 apacheConfig = let
5 theme_root' = if isNull theme_root then theme else theme_root;
6 in ''
5 <Macro Apaxy %{folder} %{ignored}> 7 <Macro Apaxy %{folder} %{ignored}>
6 Alias /theme ${if isNull theme_root then theme else theme_root} 8 Alias /theme ${theme_root'}
7 <Directory ${if isNull theme_root then theme else theme_root}> 9 <Directory ${theme_root'}>
8 Options -Indexes 10 Options -Indexes
9 AllowOverride None 11 AllowOverride None
10 Require all granted 12 Require all granted
diff --git a/pkgs/webapps/default.nix b/pkgs/webapps/default.nix
index 8151b8d..8c3eb0e 100644
--- a/pkgs/webapps/default.nix
+++ b/pkgs/webapps/default.nix
@@ -1,4 +1,4 @@
1{ callPackage, mylibs, composerEnv, lib }: 1{ callPackage, mylibs, composerEnv, lib, private }:
2rec { 2rec {
3 adminer = callPackage ./adminer {}; 3 adminer = callPackage ./adminer {};
4 apache-theme = callPackage ./apache-theme {}; 4 apache-theme = callPackage ./apache-theme {};
@@ -111,4 +111,4 @@ rec {
111 in 111 in
112 lib.attrsets.genAttrs names 112 lib.attrsets.genAttrs names
113 (name: callPackage (./yourls/plugins + "/${name}") { inherit mylibs; }); 113 (name: callPackage (./yourls/plugins + "/${name}") { inherit mylibs; });
114} 114} // private.webapps