Bookstack

From NixOS Wiki

BookStack is a platform for organising and storing information.

Installation

To install BookStack, add the following to your NixOS configuration:

services.bookstack.enable = true;

More options are available.

Configuration

BookStack uses a MySQL (MariaDB) as a DBMS, the service provides an option to create the necessary database with the necessary permissions:

services.bookstack.database.createLocally = true; # False by default

BookStack needs to know the domain on which it runs:

services.bookstack.hostname = "kb.example.com";

BookStack requires an app secret, primarily used for encryption. You can generate a valid app key using the following command:

echo base64:$(nix run nixpkgs#openssl -- rand -base64 32)

Write this value to a file owned by the bookstack user in the bookstack group, perhaps using a secret manager such as Agenix, and provide its path to Bookstack:

services.bookstack.appKeyFile = "path-to-your-secret";

And using Agenix,

services.bookstack.appKeyFile = config.age.secrets.bookstack-appkey.path;

To go further, it is useful to know that BookStack uses Laravel. So, for example, to use S3 instead of the local filesystem, check Laravel's documentation on file storage and the service definition.

Tips and tricks

Changing the default port Nginx listens on

services.bookstack.nginx.listen = [
 { addr = "[::]"; port = 8080; ssl = false;}
 { addr = "0.0.0.0"; port = 8080; ssl = false;}
 { addr = "[::]"; port = 8443; ssl = true;}
 { addr = "0.0.0.0"; port = 8443; ssl = true;}
]

Troubleshooting

"No such file or directory" in bookstack-setup

You need to connect Bookstack to a MySQL database, the service definition can install and configure one on your system with services.bookstack.database.createLocally = true;, otherwise you need to configure it yourself.