summary refs log tree commit diff
path: root/nixos/modules/services/web-apps/discourse.nix
diff options
context:
space:
mode:
authorRyan Mulligan <ryan@ryantm.com>2021-09-21 16:39:19 -0700
committerRyan Mulligan <ryan@ryantm.com>2021-09-21 16:45:59 -0700
commit6a9003f31682e57a2a630f5cfdefa2969a64b1b1 (patch)
tree37128bf336f8e40d8397f14ed1179f13eedae0a6 /nixos/modules/services/web-apps/discourse.nix
parent3175ed5b174f6d802aafa9ed363c4adfa204de32 (diff)
downloadnixpkgs-6a9003f31682e57a2a630f5cfdefa2969a64b1b1.tar
nixpkgs-6a9003f31682e57a2a630f5cfdefa2969a64b1b1.tar.gz
nixpkgs-6a9003f31682e57a2a630f5cfdefa2969a64b1b1.tar.bz2
nixpkgs-6a9003f31682e57a2a630f5cfdefa2969a64b1b1.tar.lz
nixpkgs-6a9003f31682e57a2a630f5cfdefa2969a64b1b1.tar.xz
nixpkgs-6a9003f31682e57a2a630f5cfdefa2969a64b1b1.tar.zst
nixpkgs-6a9003f31682e57a2a630f5cfdefa2969a64b1b1.zip
nixos/discourse: add discourse.admin.skipCreate option
Diffstat (limited to 'nixos/modules/services/web-apps/discourse.nix')
-rw-r--r--nixos/modules/services/web-apps/discourse.nix26
1 files changed, 20 insertions, 6 deletions
diff --git a/nixos/modules/services/web-apps/discourse.nix b/nixos/modules/services/web-apps/discourse.nix
index 050e4ee3d32..93298af2e3e 100644
--- a/nixos/modules/services/web-apps/discourse.nix
+++ b/nixos/modules/services/web-apps/discourse.nix
@@ -172,6 +172,15 @@ in
       };
 
       admin = {
+        skipCreate = lib.mkOption {
+          type = lib.types.bool;
+          default = false;
+          description = ''
+            Do not create the admin account, instead rely on other
+            existing admin accounts.
+          '';
+        };
+
         email = lib.mkOption {
           type = lib.types.str;
           example = "admin@example.com";
@@ -721,6 +730,16 @@ in
             lib.optionalString (file != null) ''
               replace-secret '${file}' '${file}' /run/discourse/config/discourse.conf
             '';
+
+          mkAdmin = ''
+            export ADMIN_EMAIL="${cfg.admin.email}"
+            export ADMIN_NAME="${cfg.admin.fullName}"
+            export ADMIN_USERNAME="${cfg.admin.username}"
+            ADMIN_PASSWORD="$(<${cfg.admin.passwordFile})"
+            export ADMIN_PASSWORD
+            discourse-rake admin:create_noninteractively
+          '';
+
         in ''
           set -o errexit -o pipefail -o nounset -o errtrace
           shopt -s inherit_errexit
@@ -750,12 +769,7 @@ in
           discourse-rake db:migrate >>/var/log/discourse/db_migration.log
           chmod -R u+w /run/discourse/tmp/
 
-          export ADMIN_EMAIL="${cfg.admin.email}"
-          export ADMIN_NAME="${cfg.admin.fullName}"
-          export ADMIN_USERNAME="${cfg.admin.username}"
-          ADMIN_PASSWORD="$(<${cfg.admin.passwordFile})"
-          export ADMIN_PASSWORD
-          discourse-rake admin:create_noninteractively
+          ${lib.optionalString (!cfg.admin.skipCreate) mkAdmin}
 
           discourse-rake themes:update
           discourse-rake uploads:regenerate_missing_optimized