]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - nixops/modules/websites/default.nix
Move production websites to use stable web directories
[perso/Immae/Config/Nix.git] / nixops / modules / websites / default.nix
index 8563995d72f47f556dfe10ecd1f3dcaac71af9be..c8f7481935ba3cae48ab7b9b3385da06758b9da9 100644 (file)
@@ -1,6 +1,8 @@
 { lib, pkgs, config, mylibs, myconfig, ... }:
 let
   cfg = config.services.myWebsites;
+  www_root = "/run/current-system/webapps/_www";
+  theme_root = "/run/current-system/webapps/_theme";
   makeService = name: cfg: let
     toVhost = vhostConf: {
       enableSSL = true;
@@ -21,9 +23,9 @@ let
       hostName = "nossl.immae.eu";
       enableSSL = false;
       logFormat = "combinedVhost";
-      documentRoot = ../../www;
+      documentRoot = www_root;
       extraConfig = ''
-        <Directory ${../../www}>
+        <Directory ${www_root}>
           DirectoryIndex nossl.html
           AllowOverride None
           Require all granted
@@ -52,7 +54,7 @@ let
     fallbackVhost = toVhost { # Should go first, default choice
       certName    = "eldiron";
       hosts       = ["eldiron.immae.eu" ];
-      root        = ../../www;
+      root        = www_root;
       extraConfig = [ "DirectoryIndex index.htm" ];
     };
   in rec {
@@ -127,6 +129,7 @@ in
     ./tools/mediagoblin
     ./tools/diaspora
     ./tools/ether
+    ./tools/peertube
     # built using:
     # sed -e "s/services\.httpd/services\.httpdProd/g" .nix-defexpr/channels/nixpkgs/nixos/modules/services/web-servers/apache-httpd/default.nix
     # Removed allGranted
@@ -208,6 +211,7 @@ in
     services.myWebsites.tools.mediagoblin.enable = true;
     services.myWebsites.tools.diaspora.enable = true;
     services.myWebsites.tools.etherpad-lite.enable = true;
+    services.myWebsites.tools.peertube.enable = true;
 
     services.myWebsites.Chloe.production.enable = cfg.production.enable;
     services.myWebsites.Ludivine.production.enable = cfg.production.enable;
@@ -288,17 +292,21 @@ in
           ErrorDocument 502 /maintenance_immae.html
           ErrorDocument 503 /maintenance_immae.html
           ErrorDocument 504 /maintenance_immae.html
-          Alias /maintenance_immae.html ${../../www}/maintenance_immae.html
+          Alias /maintenance_immae.html ${www_root}/maintenance_immae.html
           ProxyPass /maintenance_immae.html !
 
-          AliasMatch "(.*)/googleb6d69446ff4ca3e5.html" ${../../www}/googleb6d69446ff4ca3e5.html
+          AliasMatch "(.*)/googleb6d69446ff4ca3e5.html" ${www_root}/googleb6d69446ff4ca3e5.html
+          <Directory ${www_root}>
+            AllowOverride None
+            Require all granted
+          </Directory>
         '';
       };
       apaxy = {
         extraConfig = ''
           <Macro Apaxy %{folder} %{ignored}>
-            Alias /theme ${./apache/theme}
-            <Directory ${./apache/theme}>
+            Alias /theme ${theme_root}
+            <Directory ${theme_root}>
               Options -Indexes
               AllowOverride None
               Require all granted
@@ -401,10 +409,20 @@ in
         '';
     };
 
+    system.extraSystemBuilderCmds = let
+      adminer = pkgs.callPackage ./commons/adminer.nix {};
+    in ''
+      mkdir -p $out/webapps
+      ln -s ${../../www} $out/webapps/_www
+      ln -s ${./apache/theme} $out/webapps/_theme
+      ln -s ${adminer.webRoot} $out/webapps/${adminer.apache.webappName}
+      '';
+
     services.myPhpfpm = {
       phpPackage = pkgs.php;
       phpOptions = ''
         session.save_path = "/var/lib/php/sessions"
+        post_max_size = 20M
         session.gc_maxlifetime = 60*60*24*15
         session.cache_expire = 60*24*30
         '';