1 { lib, pkgs, config, ... }:
6 cfg = config.services.wiki-js;
8 format = pkgs.formats.json { };
10 configFile = format.generate "wiki-js.yml" cfg.settings;
12 options.services.wiki-js = {
13 enable = mkEnableOption "wiki-js";
15 environmentFile = mkOption {
16 type = types.nullOr types.path;
18 example = "/root/wiki-js.env";
20 Environment file to inject e.g. secrets into the configuration.
24 stateDirectoryName = mkOption {
28 Name of the directory in {file}`/var/lib`.
34 type = types.submodule {
35 freeformType = format.type;
41 TCP port the process should listen to.
49 IPs the service should listen to.
56 type = types.enum [ "postgres" "mysql" "mariadb" "mssql" ];
58 Database driver to use for persistence. Please note that `sqlite`
59 is currently not supported as the build process for it is currently not implemented
60 in `pkgs.wiki-js` and it's not recommended by upstream for
66 example = "/run/postgresql";
68 Hostname or socket-path to connect to.
75 Name of the database to use.
82 type = types.enum [ "error" "warn" "info" "verbose" "debug" "silly" ];
84 Define how much detail is supposed to be logged at runtime.
88 offline = mkEnableOption "offline mode" // {
90 Disable latest file updates and enable
91 [sideloading](https://docs.requarks.io/install/sideload).
97 Settings to configure `wiki-js`. This directly
98 corresponds to [the upstream configuration options](https://docs.requarks.io/install/config).
100 Secrets can be injected via the environment by
101 - specifying [](#opt-services.wiki-js.environmentFile)
103 - and setting sensitive values to `$(ENVIRONMENT_VAR)`
104 with this value defined in the environment-file.
109 config = mkIf cfg.enable {
110 services.wiki-js.settings.dataPath = "/var/lib/${cfg.stateDirectoryName}";
111 systemd.services.wiki-js = {
112 description = "A modern and powerful wiki app built on Node.js";
113 documentation = [ "https://docs.requarks.io/" ];
114 wantedBy = [ "multi-user.target" ];
117 # Needed for git storage.
119 # Needed for git+ssh storage.
124 ln -sf ${configFile} /var/lib/${cfg.stateDirectoryName}/config.yml
125 ln -sf ${pkgs.wiki-js}/server /var/lib/${cfg.stateDirectoryName}
126 ln -sf ${pkgs.wiki-js}/assets /var/lib/${cfg.stateDirectoryName}
127 ln -sf ${pkgs.wiki-js}/package.json /var/lib/${cfg.stateDirectoryName}/package.json
131 EnvironmentFile = mkIf (cfg.environmentFile != null) cfg.environmentFile;
132 StateDirectory = cfg.stateDirectoryName;
133 WorkingDirectory = "/var/lib/${cfg.stateDirectoryName}";
136 ExecStart = "${pkgs.nodejs_18}/bin/node ${pkgs.wiki-js}/server";
141 meta.maintainers = with maintainers; [ ma27 ];