about summary refs log tree commit diff
path: root/modules/nixos/nextcloud.nix
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--modules/nixos/nextcloud.nix164
1 files changed, 87 insertions, 77 deletions
diff --git a/modules/nixos/nextcloud.nix b/modules/nixos/nextcloud.nix
index 13cecb7..4053c38 100644
--- a/modules/nixos/nextcloud.nix
+++ b/modules/nixos/nextcloud.nix
@@ -4,9 +4,11 @@
   pkgs,
   ...
 }:
-with lib; let
+with lib;
+let
   cfg = config.nixfiles.modules.nextcloud;
-in {
+in
+{
   options.nixfiles.modules.nextcloud = {
     enable = mkEnableOption "Nextcloud";
 
@@ -21,97 +23,105 @@ in {
     nixfiles.modules = {
       nginx = {
         enable = true;
-        virtualHosts.${cfg.domain} = {};
+        virtualHosts.${cfg.domain} = { };
       };
       postgresql.enable = true;
     };
 
-    services = let
-      db = "nextcloud";
-    in {
-      nextcloud = mkMerge [
-        {
-          enable = true;
-          package = pkgs.nextcloud23;
-
-          hostName = cfg.domain;
+    services =
+      let
+        db = "nextcloud";
+      in
+      {
+        nextcloud = mkMerge [
+          {
+            enable = true;
+            package = pkgs.nextcloud23;
 
-          appstoreEnable = false;
+            hostName = cfg.domain;
 
-          config = {
-            adminpassFile = null; # This needs to be set as secret.
+            appstoreEnable = false;
 
-            dbtype = "pgsql";
-            dbhost = "/run/postgresql";
-            dbuser = db;
-            dbname = db;
+            config = {
+              adminpassFile = null; # This needs to be set as secret.
 
-            defaultPhoneRegion = "RU";
-          };
+              dbtype = "pgsql";
+              dbhost = "/run/postgresql";
+              dbuser = db;
+              dbname = db;
 
-          extraApps = let
-            mkNextcloudApp = {
-              name,
-              version,
-              hash,
-            }:
-              pkgs.fetchNextcloudApp {
-                inherit name version hash;
-                url = "https://github.com/nextcloud/${name}/archive/refs/tags/v${version}.tar.gz";
-              };
-          in {
-            contacts = mkNextcloudApp {
-              name = "contacts";
-              version = "4.0.1";
-              sha256 = "sha256-dXKsG8KmlUojeY5dUn/XsMD3KaSh4QcZFOGDdcqlSvE=";
-            };
-            calendar = mkNextcloudApp {
-              name = "calendar";
-              version = "3.0.5";
-              sha256 = "sha256-aKUKm7fWJQxOWwma56Tv+GGIo+p0n30Nhoyt4XoxsjI=";
-            };
-            files_rightclick = mkNextcloudApp {
-              name = "files_rightclick";
-              version = "23.0.1";
-              sha256 = "sha256-VYODzkvvGrtpyRoug/8UPKhAgfCx1ltP1JdGPiB/lts=";
-            };
-            unsplash = mkNextcloudApp {
-              name = "unsplash";
-              version = "1.2.4";
-              sha256 = "sha256-KGSkBOrNu0nK0YvAPYaxEL/kZNoJQD1oBV2aUBxh6cI=";
-            };
-            previewgenerator = mkNextcloudApp {
-              name = "previewgenerator";
-              version = "3.4.1";
-              sha256 = "sha256-IUdj0xWt5zHxQoiMv1bYyYTzekuOFrsRIe530QOwC/w=";
+              defaultPhoneRegion = "RU";
             };
-            bruteforcesettings = mkNextcloudApp {
-              name = "bruteforcesettings";
-              version = "2.3.0";
-              sha256 = "sha256-J7ujmiPaw8GI7vDfVPXEum2XAMWvahciP8C6iXgckdE=";
-            };
-          };
-        }
-        (mkIf config.nixfiles.modules.acme.enable {
-          https = true;
-          config.overwriteProtocol = "https";
-        })
-      ];
 
-      postgresql = {
-        ensureDatabases = [db];
-        ensureUsers = [
-          {
-            name = db;
-            ensureDBOwnership = true;
+            extraApps =
+              let
+                mkNextcloudApp =
+                  {
+                    name,
+                    version,
+                    hash,
+                  }:
+                  pkgs.fetchNextcloudApp {
+                    inherit name version hash;
+                    url = "https://github.com/nextcloud/${name}/archive/refs/tags/v${version}.tar.gz";
+                  };
+              in
+              {
+                contacts = mkNextcloudApp {
+                  name = "contacts";
+                  version = "4.0.1";
+                  sha256 = "sha256-dXKsG8KmlUojeY5dUn/XsMD3KaSh4QcZFOGDdcqlSvE=";
+                };
+                calendar = mkNextcloudApp {
+                  name = "calendar";
+                  version = "3.0.5";
+                  sha256 = "sha256-aKUKm7fWJQxOWwma56Tv+GGIo+p0n30Nhoyt4XoxsjI=";
+                };
+                files_rightclick = mkNextcloudApp {
+                  name = "files_rightclick";
+                  version = "23.0.1";
+                  sha256 = "sha256-VYODzkvvGrtpyRoug/8UPKhAgfCx1ltP1JdGPiB/lts=";
+                };
+                unsplash = mkNextcloudApp {
+                  name = "unsplash";
+                  version = "1.2.4";
+                  sha256 = "sha256-KGSkBOrNu0nK0YvAPYaxEL/kZNoJQD1oBV2aUBxh6cI=";
+                };
+                previewgenerator = mkNextcloudApp {
+                  name = "previewgenerator";
+                  version = "3.4.1";
+                  sha256 = "sha256-IUdj0xWt5zHxQoiMv1bYyYTzekuOFrsRIe530QOwC/w=";
+                };
+                bruteforcesettings = mkNextcloudApp {
+                  name = "bruteforcesettings";
+                  version = "2.3.0";
+                  sha256 = "sha256-J7ujmiPaw8GI7vDfVPXEum2XAMWvahciP8C6iXgckdE=";
+                };
+              };
           }
+          (mkIf config.nixfiles.modules.acme.enable {
+            https = true;
+            config.overwriteProtocol = "https";
+          })
         ];
+
+        postgresql = {
+          ensureDatabases = [ db ];
+          ensureUsers = [
+            {
+              name = db;
+              ensureDBOwnership = true;
+            }
+          ];
+        };
       };
-    };
 
     systemd = {
       services = {
-        nextcloud-setup.after = ["network-online.target" "postgresql.service"];
+        nextcloud-setup.after = [
+          "network-online.target"
+          "postgresql.service"
+        ];
 
         nextcloud-preview-generate-cron.serviceConfig = {
           Type = "oneshot";
@@ -121,7 +131,7 @@ in {
       };
 
       timers.nextcloud-preview-generate = {
-        wantedBy = ["timers.target"];
+        wantedBy = [ "timers.target" ];
         timerConfig = {
           OnBootSec = "15m";
           OnUnitActiveSec = "15m";

Consider giving Nix/NixOS a try! <3