2020-11-29 20:51:50 +03:00
|
|
|
import ./make-test-python.nix ({ pkgs, lib, ... }:
|
|
|
|
{
|
|
|
|
name = "hedgedoc";
|
|
|
|
|
|
|
|
meta = with lib.maintainers; {
|
|
|
|
maintainers = [ willibutz ];
|
|
|
|
};
|
|
|
|
|
|
|
|
nodes = {
|
|
|
|
hedgedocSqlite = { ... }: {
|
|
|
|
services = {
|
|
|
|
hedgedoc = {
|
|
|
|
enable = true;
|
2022-06-02 18:38:06 +03:00
|
|
|
settings.dbURL = "sqlite:///var/lib/hedgedoc/hedgedoc.db";
|
2020-11-29 20:51:50 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
hedgedocPostgres = { ... }: {
|
|
|
|
systemd.services.hedgedoc.after = [ "postgresql.service" ];
|
|
|
|
services = {
|
|
|
|
hedgedoc = {
|
|
|
|
enable = true;
|
2022-06-02 18:38:06 +03:00
|
|
|
settings.dbURL = "postgres://hedgedoc:\${DB_PASSWORD}@localhost:5432/hedgedocdb";
|
2020-11-29 20:51:50 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Do not use pkgs.writeText for secrets as
|
|
|
|
* they will end up in the world-readable Nix store.
|
|
|
|
*/
|
|
|
|
environmentFile = pkgs.writeText "hedgedoc-env" ''
|
|
|
|
DB_PASSWORD=snakeoilpassword
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
postgresql = {
|
|
|
|
enable = true;
|
|
|
|
initialScript = pkgs.writeText "pg-init-script.sql" ''
|
|
|
|
CREATE ROLE hedgedoc LOGIN PASSWORD 'snakeoilpassword';
|
|
|
|
CREATE DATABASE hedgedocdb OWNER hedgedoc;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
|
|
|
start_all()
|
|
|
|
|
|
|
|
with subtest("HedgeDoc sqlite"):
|
|
|
|
hedgedocSqlite.wait_for_unit("hedgedoc.service")
|
|
|
|
hedgedocSqlite.wait_for_open_port(3000)
|
|
|
|
hedgedocSqlite.wait_until_succeeds("curl -sSf http://localhost:3000/new")
|
|
|
|
|
|
|
|
with subtest("HedgeDoc postgres"):
|
|
|
|
hedgedocPostgres.wait_for_unit("postgresql.service")
|
|
|
|
hedgedocPostgres.wait_for_unit("hedgedoc.service")
|
|
|
|
hedgedocPostgres.wait_for_open_port(5432)
|
|
|
|
hedgedocPostgres.wait_for_open_port(3000)
|
|
|
|
hedgedocPostgres.wait_until_succeeds("curl -sSf http://localhost:3000/new")
|
|
|
|
'';
|
|
|
|
})
|