1 { pkgs, lib, config, ... }:
6 cfg = config.services.documize;
8 mkParams = optional: concatMapStrings (name: let
9 predicate = optional -> cfg.${name} != null;
10 template = " -${name} '${toString cfg.${name}}'";
11 in optionalString predicate template);
14 options.services.documize = {
15 enable = mkEnableOption "Documize Wiki";
17 stateDirectoryName = mkOption {
21 The name of the directory below {file}`/var/lib/private`
22 where documize runs in and stores, for example, backups.
26 package = mkPackageOption pkgs "documize-community" { };
29 type = types.nullOr types.str;
31 example = "3edIYV6c8B28b19fh";
33 The salt string used to encode JWT tokens, if not set a random value will be generated.
38 type = types.nullOr types.str;
41 The {file}`cert.pem` file used for https.
46 type = types.nullOr types.str;
49 The {file}`key.pem` file used for https.
57 The http/https port number.
61 forcesslport = mkOption {
62 type = types.nullOr types.port;
65 Redirect given http port number to TLS.
73 Set `true` for offline mode.
75 apply = v: if true == v then 1 else 0;
79 type = types.enum [ "mysql" "percona" "mariadb" "postgresql" "sqlserver" ];
80 default = "postgresql";
82 Specify the database provider: `mysql`, `percona`, `mariadb`, `postgresql`, `sqlserver`
89 Database specific connection string for example:
90 - MySQL/Percona/MariaDB:
91 `user:password@tcp(host:3306)/documize`
93 `user:password@tcp(host:3306)/documize?allowNativePasswords=true`
95 `host=localhost port=5432 dbname=documize user=admin password=secret sslmode=disable`
97 `sqlserver://username:password@localhost:1433?database=Documize` or
98 `sqlserver://sa@localhost/SQLExpress?database=Documize`
102 location = mkOption {
103 type = types.nullOr types.str;
111 config = mkIf cfg.enable {
112 systemd.services.documize-server = {
113 description = "Documize Wiki";
114 documentation = [ "https://documize.com/" ];
115 wantedBy = [ "multi-user.target" ];
118 ExecStart = concatStringsSep " " [
119 "${cfg.package}/bin/documize"
120 (mkParams false [ "db" "dbtype" "port" ])
121 (mkParams true [ "offline" "location" "forcesslport" "key" "cert" "salt" ])
125 StateDirectory = cfg.stateDirectoryName;
126 WorkingDirectory = "/var/lib/${cfg.stateDirectoryName}";