aboutsummaryrefslogtreecommitdiff
path: root/modules/websites/default.nix
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-12-24 09:41:27 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-12-24 11:11:56 +0100
commit9a414bd66ff06cade504ac34f13dbeddac48150a (patch)
tree9db0a325f2024aac46d1d61a07f97cfd923abc2d /modules/websites/default.nix
parent253c6f8a634bdcde3e13a2c79f1fd479bb181cbf (diff)
downloadNix-9a414bd66ff06cade504ac34f13dbeddac48150a.tar.gz
Nix-9a414bd66ff06cade504ac34f13dbeddac48150a.tar.zst
Nix-9a414bd66ff06cade504ac34f13dbeddac48150a.zip
Add maison bbc website
Diffstat (limited to 'modules/websites/default.nix')
-rw-r--r--modules/websites/default.nix21
1 files changed, 21 insertions, 0 deletions
diff --git a/modules/websites/default.nix b/modules/websites/default.nix
index 043fc6e..6ba0d68 100644
--- a/modules/websites/default.nix
+++ b/modules/websites/default.nix
@@ -86,6 +86,17 @@ in
86 }; 86 };
87 }; 87 };
88 }; 88 };
89 vhostNoSSLConfs = mkOption {
90 default = {};
91 description = "List of no ssl vhosts to define for Apache";
92 type = attrsOf (submodule {
93 options = {
94 hosts = mkOption { type = listOf string; };
95 root = mkOption { type = nullOr path; };
96 extraConfig = mkOption { type = listOf lines; default = []; };
97 };
98 });
99 };
89 vhostConfs = mkOption { 100 vhostConfs = mkOption {
90 default = {}; 101 default = {};
91 description = "List of vhosts to define for Apache"; 102 description = "List of vhosts to define for Apache";
@@ -177,6 +188,15 @@ in
177 documentRoot = vhostConf.root; 188 documentRoot = vhostConf.root;
178 extraConfig = builtins.concatStringsSep "\n" vhostConf.extraConfig; 189 extraConfig = builtins.concatStringsSep "\n" vhostConf.extraConfig;
179 }; 190 };
191 toVhostNoSSL = ips: vhostConf: {
192 enableSSL = false;
193 logFormat = "combinedVhost";
194 listen = map (ip: { inherit ip; port = 80; }) ips;
195 hostName = builtins.head vhostConf.hosts;
196 serverAliases = builtins.tail vhostConf.hosts or [];
197 documentRoot = vhostConf.root;
198 extraConfig = builtins.concatStringsSep "\n" vhostConf.extraConfig;
199 };
180 in attrsets.mapAttrs' (name: icfg: attrsets.nameValuePair 200 in attrsets.mapAttrs' (name: icfg: attrsets.nameValuePair
181 icfg.httpdName (mkIf icfg.enable { 201 icfg.httpdName (mkIf icfg.enable {
182 enable = true; 202 enable = true;
@@ -190,6 +210,7 @@ in
190 extraConfig = builtins.concatStringsSep "\n" icfg.extraConfig; 210 extraConfig = builtins.concatStringsSep "\n" icfg.extraConfig;
191 virtualHosts = [ (toVhost icfg.ips icfg.fallbackVhost) ] 211 virtualHosts = [ (toVhost icfg.ips icfg.fallbackVhost) ]
192 ++ optionals (icfg.nosslVhost.enable) [ (nosslVhost icfg.ips icfg.nosslVhost) ] 212 ++ optionals (icfg.nosslVhost.enable) [ (nosslVhost icfg.ips icfg.nosslVhost) ]
213 ++ (attrsets.mapAttrsToList (n: v: toVhostNoSSL icfg.ips v) icfg.vhostNoSSLConfs)
193 ++ (attrsets.mapAttrsToList (n: v: toVhost icfg.ips v) icfg.vhostConfs) 214 ++ (attrsets.mapAttrsToList (n: v: toVhost icfg.ips v) icfg.vhostConfs)
194 ++ [ (redirectVhost icfg.ips) ]; 215 ++ [ (redirectVhost icfg.ips) ];
195 }) 216 })