From 84a86b6041c678b6f91ea277f8316ba14ab4636c Mon Sep 17 00:00:00 2001 From: Savyasachee Jha Date: Tue, 10 Jun 2025 21:42:56 +0530 Subject: [PATCH] nixosTests.bookstack: init --- nixos/tests/all-tests.nix | 1 + nixos/tests/bookstack.nix | 45 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 nixos/tests/bookstack.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index cc4f7641b827..05e34212ced6 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -254,6 +254,7 @@ in bittorrent = runTest ./bittorrent.nix; blockbook-frontend = runTest ./blockbook-frontend.nix; blocky = handleTest ./blocky.nix { }; + bookstack = runTest ./bookstack.nix; boot = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./boot.nix { }; bootspec = handleTestOn [ "x86_64-linux" ] ./bootspec.nix { }; boot-stage1 = runTest ./boot-stage1.nix; diff --git a/nixos/tests/bookstack.nix b/nixos/tests/bookstack.nix new file mode 100644 index 000000000000..a0c9b39c1c0e --- /dev/null +++ b/nixos/tests/bookstack.nix @@ -0,0 +1,45 @@ +{ pkgs, ... }: + +let + db-pass = "Test2Test2"; + app-key = "TestTestTestTestTestTestTestTest"; +in +{ + name = "bookstack"; + meta.maintainers = [ pkgs.lib.maintainers.savyajha ]; + + nodes.bookstackMysql = { + services.bookstack = { + enable = true; + hostname = "localhost"; + nginx.onlySSL = false; + settings = { + APP_KEY_FILE = pkgs.writeText "bookstack-appkey" app-key; + LOG_CHANNEL = "stdout"; + SITE_OWNER = "mail@example.com"; + DB_DATABASE = "bookstack"; + DB_USERNAME = "bookstack"; + DB_PASSWORD_FILE = pkgs.writeText "mysql-pass" db-pass; + DB_SOCKET = "/run/mysqld/mysqld.sock"; + }; + }; + + services.mysql = { + enable = true; + package = pkgs.mariadb; + initialScript = pkgs.writeText "bookstack-init.sql" '' + create database bookstack DEFAULT CHARACTER SET utf8mb4; + create user 'bookstack'@'localhost' identified by '${db-pass}'; + grant all on bookstack.* to 'bookstack'@'localhost'; + ''; + settings.mysqld.character-set-server = "utf8mb4"; + }; + }; + + testScript = '' + bookstackMysql.wait_for_unit("phpfpm-bookstack.service") + bookstackMysql.wait_for_unit("nginx.service") + bookstackMysql.wait_for_unit("mysql.service") + bookstackMysql.succeed("curl -fvvv -Ls http://localhost/ | grep 'Log In'") + ''; +}