summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2019-01-14 15:56:20 +0100
committerMaximilian Bosch <maximilian@mbosch.me>2019-01-14 16:04:02 +0100
commitad3a50e25bf2fa029ce772b443b1717ebdb67f4a (patch)
treeb8ae7e11190d5f4ddd40cf4e968528a67dbb618e /nixos
parent9651cc7a93a2d71aad0eea00dbde7cce77735b18 (diff)
downloadnixpkgs-ad3a50e25bf2fa029ce772b443b1717ebdb67f4a.tar
nixpkgs-ad3a50e25bf2fa029ce772b443b1717ebdb67f4a.tar.gz
nixpkgs-ad3a50e25bf2fa029ce772b443b1717ebdb67f4a.tar.bz2
nixpkgs-ad3a50e25bf2fa029ce772b443b1717ebdb67f4a.tar.lz
nixpkgs-ad3a50e25bf2fa029ce772b443b1717ebdb67f4a.tar.xz
nixpkgs-ad3a50e25bf2fa029ce772b443b1717ebdb67f4a.tar.zst
nixpkgs-ad3a50e25bf2fa029ce772b443b1717ebdb67f4a.zip
nixos/gitea: add option to disable registration
Although this can be added to `extraOptions` I figured that it makes
sense to add an option to explicitly promote this feature in our
documentation since most of the self-hosted gitea instances won't be
intended for common use I guess.

Also added a notice that this should be added after the initial deploy
as you have to register yourself using that feature unless the install
wizard is used.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/misc/gitea.nix15
-rw-r--r--nixos/tests/gitea.nix2
2 files changed, 17 insertions, 0 deletions
diff --git a/nixos/modules/services/misc/gitea.nix b/nixos/modules/services/misc/gitea.nix
index 7a10bd87299..9a646000981 100644
--- a/nixos/modules/services/misc/gitea.nix
+++ b/nixos/modules/services/misc/gitea.nix
@@ -46,6 +46,9 @@ let
     ROOT_PATH = ${cfg.log.rootPath}
     LEVEL = ${cfg.log.level}
 
+    [service]
+    DISABLE_REGISTRATION = ${boolToString cfg.disableRegistration}
+
     ${cfg.extraConfig}
   '';
 in
@@ -248,6 +251,18 @@ in
         description = "Upper level of template and static files path.";
       };
 
+      disableRegistration = mkEnableOption "the registration lock" // {
+        description = ''
+          By default any user can create an account on this <literal>gitea</literal> instance.
+          This can be disabled by using this option.
+
+          <emphasis>Note:</emphasis> please keep in mind that this should be added after the initial
+          deploy unless <link linkend="opt-services.gitea.useWizard">services.gitea.useWizard</link>
+          is <literal>true</literal> as the first registered user will be the administrator if
+          no install wizard is used.
+        '';
+      };
+
       extraConfig = mkOption {
         type = types.str;
         default = "";
diff --git a/nixos/tests/gitea.nix b/nixos/tests/gitea.nix
index 35433499185..28e6479e9cb 100644
--- a/nixos/tests/gitea.nix
+++ b/nixos/tests/gitea.nix
@@ -64,6 +64,7 @@ with pkgs.lib;
     machine =
       { config, pkgs, ... }:
       { services.gitea.enable = true;
+        services.gitea.disableRegistration = true;
       };
 
     testScript = ''
@@ -72,6 +73,7 @@ with pkgs.lib;
       $machine->waitForUnit('gitea.service');
       $machine->waitForOpenPort('3000');
       $machine->succeed("curl --fail http://localhost:3000/");
+      $machine->succeed("curl --fail http://localhost:3000/user/sign_up | grep 'Registration is disabled. Please contact your site administrator.'");
     '';
   };
 }