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.
This commit is contained in:
@@ -24,6 +24,7 @@ let
|
|||||||
$sudo ${pkgs.php}/bin/php artisan $*
|
$sudo ${pkgs.php}/bin/php artisan $*
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
tlsEnabled = cfg.nginx.addSSL || cfg.nginx.forceSSL || cfg.nginx.onlySSL || cfg.nginx.enableACME;
|
||||||
|
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
@@ -55,11 +56,26 @@ in {
|
|||||||
type = types.path;
|
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 {
|
appURL = mkOption {
|
||||||
description = ''
|
description = ''
|
||||||
The root URL that you want to host BookStack on. All URLs in BookStack will be generated using this value.
|
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>
|
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";
|
example = "https://example.com";
|
||||||
type = types.str;
|
type = types.str;
|
||||||
};
|
};
|
||||||
@@ -256,7 +272,7 @@ in {
|
|||||||
|
|
||||||
services.nginx = {
|
services.nginx = {
|
||||||
enable = mkDefault true;
|
enable = mkDefault true;
|
||||||
virtualHosts.bookstack = mkMerge [ cfg.nginx {
|
virtualHosts.${cfg.hostname} = mkMerge [ cfg.nginx {
|
||||||
root = mkForce "${bookstack}/public";
|
root = mkForce "${bookstack}/public";
|
||||||
extraConfig = optionalString (cfg.nginx.addSSL || cfg.nginx.forceSSL || cfg.nginx.onlySSL || cfg.nginx.enableACME) "fastcgi_param HTTPS on;";
|
extraConfig = optionalString (cfg.nginx.addSSL || cfg.nginx.forceSSL || cfg.nginx.onlySSL || cfg.nginx.enableACME) "fastcgi_param HTTPS on;";
|
||||||
locations = {
|
locations = {
|
||||||
|
|||||||
Reference in New Issue
Block a user