]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - virtual/modules/websites/aten/aten.nix
Remove use of environment variables
[perso/Immae/Config/Nix.git] / virtual / modules / websites / aten / aten.nix
index 7eec525bbe595456b724c1d81a9f2aabcece0a65..1520439e349eef427dd248c00203e7ab64ffe6f0 100644 (file)
@@ -1,9 +1,8 @@
-{ lib, checkEnv, writeText, fetchedGitPrivate, stdenv, php, git, cacert, phpPackages, yarn }:
+{ lib, writeText, fetchedGitPrivate, stdenv, php, git, cacert, phpPackages, yarn }:
 let
-  aten = { environment ? "dev" }: rec {
-    varPrefix = "ATEN";
+  aten = { config }: rec {
+    environment = config.environment;
     varDir = "/var/lib/aten_${environment}";
-    envName= lib.strings.toUpper environment;
     phpFpm = rec {
       socket = "/var/run/phpfpm/aten-${environment}.sock";
       pool = ''
@@ -34,17 +33,14 @@ let
       user = "wwwrun";
       group = "wwwrun";
       modules = [ "proxy_fcgi" ];
-      vhostConf =
-        assert checkEnv "NIXOPS_${varPrefix}_${envName}_SECRET";
-        assert checkEnv "NIXOPS_${varPrefix}_${envName}_PSQL_URL";
-      ''
+      vhostConf = ''
       <FilesMatch "\.php$">
         SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
       </FilesMatch>
 
       SetEnv APP_ENV      "${environment}"
-      SetEnv APP_SECRET   "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_SECRET"}
-      SetEnv DATABASE_URL "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_PSQL_URL"}
+      SetEnv APP_SECRET   "${config.secret}"
+      SetEnv DATABASE_URL "${config.psql_url}"
 
       ${if environment == "dev" then ''
       <Location />
@@ -96,8 +92,8 @@ let
         export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
         export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
         export APP_ENV="${environment}"
-        export DATABASE_URL="${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_PSQL_URL"}"
-        export APP_SECRET="${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_SECRET"}"
+        export DATABASE_URL="${config.psql_url}"
+        export APP_SECRET="${config.secret}"
 
         ${if environment == "dev" then ''
           composer install