summary refs log tree commit diff
path: root/nixos/modules/services/web-apps
diff options
context:
space:
mode:
authortalyz <kim.lindberger@gmail.com>2022-01-11 13:36:52 +0100
committertalyz <kim.lindberger@gmail.com>2022-01-18 15:16:11 +0100
commitdf607c1d1f6ea9ad5fcc99a0cabba0ede4be0d4e (patch)
treef08cf25e8c495efebf05239992e0a47c2a80cf3d /nixos/modules/services/web-apps
parente7fa7fdffc8c37239fb98e1d902a932cad066ea5 (diff)
downloadnixpkgs-df607c1d1f6ea9ad5fcc99a0cabba0ede4be0d4e.tar
nixpkgs-df607c1d1f6ea9ad5fcc99a0cabba0ede4be0d4e.tar.gz
nixpkgs-df607c1d1f6ea9ad5fcc99a0cabba0ede4be0d4e.tar.bz2
nixpkgs-df607c1d1f6ea9ad5fcc99a0cabba0ede4be0d4e.tar.lz
nixpkgs-df607c1d1f6ea9ad5fcc99a0cabba0ede4be0d4e.tar.xz
nixpkgs-df607c1d1f6ea9ad5fcc99a0cabba0ede4be0d4e.tar.zst
nixpkgs-df607c1d1f6ea9ad5fcc99a0cabba0ede4be0d4e.zip
nixos/bookstack: Make the hostname configurable...
...and set a reasonable default `appURL` based on it.

This is pretty much required when configuring ACME, and useful in
general.
Diffstat (limited to 'nixos/modules/services/web-apps')
-rw-r--r--nixos/modules/services/web-apps/bookstack.nix18
1 files changed, 17 insertions, 1 deletions
diff --git a/nixos/modules/services/web-apps/bookstack.nix b/nixos/modules/services/web-apps/bookstack.nix
index 1124568e8d3..62a04bccc66 100644
--- a/nixos/modules/services/web-apps/bookstack.nix
+++ b/nixos/modules/services/web-apps/bookstack.nix
@@ -24,6 +24,7 @@ let
     $sudo ${pkgs.php}/bin/php artisan $*
   '';
 
+  tlsEnabled = cfg.nginx.addSSL || cfg.nginx.forceSSL || cfg.nginx.onlySSL || cfg.nginx.enableACME;
 
 in {
   imports = [
@@ -55,11 +56,26 @@ in {
       type = types.path;
     };
 
+    hostname = lib.mkOption {
+      type = lib.types.str;
+      default = if config.networking.domain != null then
+                  config.networking.fqdn
+                else
+                  config.networking.hostName;
+      defaultText = lib.literalExpression "config.networking.fqdn";
+      example = "bookstack.example.com";
+      description = ''
+        The hostname to serve BookStack on.
+      '';
+    };
+
     appURL = mkOption {
       description = ''
         The root URL that you want to host BookStack on. All URLs in BookStack will be generated using this value.
         If you change this in the future you may need to run a command to update stored URLs in the database. Command example: <code>php artisan bookstack:update-url https://old.example.com https://new.example.com</code>
       '';
+      default = "http${lib.optionalString tlsEnabled "s"}://${cfg.hostname}";
+      defaultText = ''http''${lib.optionalString tlsEnabled "s"}://''${cfg.hostname}'';
       example = "https://example.com";
       type = types.str;
     };
@@ -256,7 +272,7 @@ in {
 
     services.nginx = {
       enable = mkDefault true;
-      virtualHosts.bookstack = mkMerge [ cfg.nginx {
+      virtualHosts.${cfg.hostname} = mkMerge [ cfg.nginx {
         root = mkForce "${bookstack}/public";
         extraConfig = optionalString (cfg.nginx.addSSL || cfg.nginx.forceSSL || cfg.nginx.onlySSL || cfg.nginx.enableACME) "fastcgi_param HTTPS on;";
         locations = {