]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - nixops/modules/websites/aten/aten.nix
Fix apache certificate chain containing the cert in double
[perso/Immae/Config/Nix.git] / nixops / modules / websites / aten / aten.nix
index 715f68967e16a2fe31ae1d19e2bdbdf71cc07bed..d9286c3fa7bd402ccfadd2f6e0d3d9100cfaf5c1 100644 (file)
@@ -1,4 +1,4 @@
-{ lib, writeText, fetchedGitPrivate, stdenv, composerEnv, fetchurl, fetchgit, python, nodejs, libsass, yarn2nix }:
+{ lib, writeText, fetchedGitPrivate, stdenv, runCommand, composerEnv, fetchurl, fetchgit, jq, python, nodejs, libsass, yarn2nixPackage }:
 let
   aten = { config }: rec {
     environment = config.environment;
@@ -29,10 +29,12 @@ let
         pm.max_spare_servers = 3
         ''}'';
     };
-    apache = {
+    apache = rec {
       user = "wwwrun";
       group = "wwwrun";
       modules = [ "proxy_fcgi" ];
+      webappName = "aten_${environment}";
+      root = "/run/current-system/webapps/${webappName}";
       vhostConf = ''
       <FilesMatch "\.php$">
         SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
@@ -64,7 +66,7 @@ let
       </Location>
       ''}
 
-      <Directory ${webRoot}>
+      <Directory ${root}>
         Options Indexes FollowSymLinks MultiViews Includes
         AllowOverride All
         Require all granted
@@ -89,10 +91,15 @@ let
     };
     yarnModules = let
         info = fetchedGitPrivate ./aten.json;
+        packagejson = runCommand "package.json" { buildInputs = [ jq ]; } ''
+          cat ${info.src}/package.json | jq -r '.version = "v1.0.0"|.name="aten"' > $out
+          '';
       in
-        yarn2nix.mkYarnModules {
-          name = "aten-yarn-modules";
-          packageJSON = "${info.src}/package.json";
+        yarn2nixPackage.mkYarnModules rec {
+          name = "aten-yarn";
+          pname = name;
+          version = "v1.0.0";
+          packageJSON = packagejson;
           yarnLock = "${info.src}/yarn.lock";
           pkgConfig = {
             node-sass = {
@@ -100,7 +107,7 @@ let
               postInstall = let
                 nodeHeaders = fetchurl {
                   url = "https://nodejs.org/download/release/v${nodejs.version}/node-v${nodejs.version}-headers.tar.gz";
-                  sha256 = "12zzsf8my43b8qnlacp871ih5vqafl2vlpqp51xp6h3gckn2frwy";
+                  sha256 = "16f20ya3ys6w5w6y6l4536f7jrgk4gz46bf71w1r1xxb26a54m32";
                 };
               in
                 ''
@@ -121,13 +128,12 @@ let
           export APP_SECRET="${config.secret}"
           '';
         postInstall = ''
-          cd $out
           ln -sf ${yarnModules}/node_modules .
           yarn run --offline encore production
           rm -rf var/{log,cache}
-          ln -sf ../../../../../../../${varDir}/{log,cache} var/
+          ln -sf ${varDir}/{log,cache} var/
           '';
-        buildInputs = [ yarn2nix.yarn ];
+        buildInputs = [ yarnModules yarn2nixPackage.yarn ];
       });
     webRoot = "${webappDir}/public";
   };