]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - virtual/modules/websites/tools/cloud/nextcloud.nix
Put some database variables to environment
[perso/Immae/Config/Nix.git] / virtual / modules / websites / tools / cloud / nextcloud.nix
index 5849774f8afe9137583211166cc969173ea9b39e..3c6bfc9505e79b209a3c78498d01b0985e2a9e3f 100644 (file)
@@ -1,8 +1,6 @@
-{ stdenv, fetchurl, checkEnv, writeText, lib, phpPackages, php }:
+{ stdenv, fetchurl, env, writeText, lib, phpPackages, php }:
 let
   nextcloud = let
-    # FIXME: initial sync
-    # FIXME: backup
     buildApp = { appName, version, url, sha256, installPhase ? "mkdir -p $out && cp -R . $out/" }:
       stdenv.mkDerivation rec {
         name = "nextcloud-app-${appName}-${version}";
@@ -12,11 +10,6 @@ let
         src = fetchurl { inherit url sha256; };
       };
     apps = {
-      # FIXME: nextcloud complains that he cannot write into config
-      # directory when an app needs upgrade
-      # /!\ Attention, just changing the version number is not
-      # sufficient when the downloaded file doesn’t contain the version
-      # number in it, sha256 needs to be recomputed
       audioplayer = buildApp rec {
         appName = "audioplayer";
         version = "2.5.0";
@@ -103,27 +96,20 @@ let
     };
   in rec {
     varDir = "/var/lib/nextcloud";
-    config_php =
-      assert checkEnv "NIXOPS_NEXTCLOUD_PASSWORD_SALT";
-      assert checkEnv "NIXOPS_NEXTCLOUD_DB_USER";
-      assert checkEnv "NIXOPS_NEXTCLOUD_DB_PASSWORD";
-      assert checkEnv "NIXOPS_NEXTCLOUD_INSTANCE_ID";
-      assert checkEnv "NIXOPS_NEXTCLOUD_SECRET";
-      assert checkEnv "NIXOPS_NEXTCLOUD_REDIS_DB_INDEX";
-      writeText "config.php" ''
+    config_php = writeText "config.php" ''
       <?php
       $CONFIG = array (
-        'instanceid' => '${builtins.getEnv "NIXOPS_NEXTCLOUD_INSTANCE_ID"}',
+        'instanceid' => '${env.instance_id}',
         'datadirectory' => '/var/lib/nextcloud/',
-        'passwordsalt' => '${builtins.getEnv "NIXOPS_NEXTCLOUD_PASSWORD_SALT"}',
+        'passwordsalt' => '${env.password_salt}',
         'debug' => false,
         'dbtype' => 'pgsql',
         'version' => '15.0.0.10',
-        'dbname' => 'webapps',
-        'dbhost' => '/run/postgresql',
+        'dbname' => '${env.postgresql.database}',
+        'dbhost' => '${env.postgresql.socket}',
         'dbtableprefix' => 'oc_',
-        'dbuser' => '${builtins.getEnv "NIXOPS_NEXTCLOUD_DB_USER"}',
-        'dbpassword' => '${builtins.getEnv "NIXOPS_NEXTCLOUD_DB_PASSWORD"}',
+        'dbuser' => '${env.postgresql.user}',
+        'dbpassword' => '${env.postgresql.password}',
         'installed' => true,
         'maxZipInputSize' => 0,
         'allowZipDownload' => true,
@@ -134,7 +120,7 @@ let
         array (
           0 => 'cloud.immae.eu',
         ),
-        'secret' => '${builtins.getEnv "NIXOPS_NEXTCLOUD_SECRET"}',
+        'secret' => '${env.secret}',
         'appstoreenabled' => false,
         'appstore.experimental.enabled' => true,
         'loglevel' => 0,
@@ -152,9 +138,9 @@ let
         'filelocking.enabled' => true,
         'redis' =>
         array (
-          'host' => 'localhost',
-          'port' => 6379,
-          'dbindex' => ${builtins.getEnv "NIXOPS_NEXTCLOUD_REDIS_DB_INDEX"},
+          'host' => '${env.redis.socket}',
+          'port' => 0,
+          'dbindex' => ${env.redis.db_index},
         ),
         'overwrite.cli.url' => 'https://cloud.immae.eu',
         'ldapIgnoreNamingRules' => false,