10 cfg = config.services.collabora-online;
12 freeformType = lib.types.attrsOf ((pkgs.formats.json { }).type) // {
14 `coolwsd.xml` configuration type, used to override values in the default configuration.
16 Attribute names correspond to XML tags unless prefixed with `@`. Nested attribute sets
17 correspond to nested XML tags. Attribute prefixed with `@` correspond to XML attributes. E.g.,
18 `{ storage.wopi."@allow" = true; }` in Nix corresponds to
19 `<storage><wopi allow="true"/></storage>` in `coolwsd.xml`, or `--o:storage.wopi[@allow]=true`
22 Arrays correspond to multiple elements with the same tag name. E.g.
23 `{ host = [ '''127\.0\.0\.1''' "::1" ]; }` in Nix corresponds to
26 <host>127\.0\.0\.1</host>
31 `--o:net.post_allow.host[0]='127\.0\.0\.1 --o:net.post_allow.host[1]=::1` in the command line.
33 Null values could be used to remove an element from the default configuration.
38 pkgs.runCommandLocal "coolwsd.xml"
44 userConfig = builtins.toJSON { config = cfg.settings; };
45 passAsFile = [ "userConfig" ];
47 # Merge the cfg.settings into the default coolwsd.xml.
48 # See https://github.com/CollaboraOnline/online/issues/10049.
50 yq --input-format=xml \
51 --xml-attribute-prefix=@ \
52 --output-format=json \
53 ${cfg.package}/etc/coolwsd/coolwsd.xml \
54 > ./default_coolwsd.json
56 jq '.[0] * .[1] | del(..|nulls)' \
58 ./default_coolwsd.json \
62 yq --output-format=xml \
63 --xml-attribute-prefix=@ \
69 options.services.collabora-online = {
70 enable = lib.mkEnableOption "collabora-online";
72 package = lib.mkPackageOption pkgs "Collabora Online" { default = "collabora-online"; };
75 type = lib.types.port;
77 description = "Listening port";
80 settings = lib.mkOption {
84 Configuration for Collabora Online WebSocket Daemon, see
85 <https://sdk.collaboraonline.com/docs/installation/Configuration.html>, or
86 <https://github.com/CollaboraOnline/online/blob/master/coolwsd.xml.in> for the default
91 aliasGroups = lib.mkOption {
92 type = lib.types.listOf (
97 example = "scheme://hostname:port";
98 description = "Hostname to allow or deny.";
101 aliases = lib.mkOption {
102 type = lib.types.listOf lib.types.str;
105 "scheme://aliasname1:port"
106 "scheme://aliasname2:port"
108 description = "A list of regex pattern of aliasname.";
114 description = "Alias groups to use.";
117 extraArgs = lib.mkOption {
118 type = lib.types.listOf lib.types.str;
120 description = "Extra arguments to pass to the service.";
124 config = lib.mkIf cfg.enable {
125 services.collabora-online.settings = {
126 child_root_path = lib.mkDefault "/var/lib/cool/child-roots";
127 sys_template_path = lib.mkDefault "/var/lib/cool/systemplate";
129 file_server_root_path = lib.mkDefault "${config.services.collabora-online.package}/share/coolwsd";
131 # Use mount namespaces instead of setcap'd coolmount/coolforkit.
132 mount_namespaces = lib.mkDefault true;
134 # By default, use dummy self-signed certificates provided for testing.
135 ssl.ca_file_path = lib.mkDefault "${config.services.collabora-online.package}/etc/coolwsd/ca-chain.cert.pem";
136 ssl.cert_file_path = lib.mkDefault "${config.services.collabora-online.package}/etc/coolwsd/cert.pem";
137 ssl.key_file_path = lib.mkDefault "${config.services.collabora-online.package}/etc/coolwsd/key.pem";
144 users.groups.cool = { };
146 systemd.services.coolwsd-systemplate-setup = {
147 description = "Collabora Online WebSocket Daemon Setup";
148 wantedBy = [ "multi-user.target" ];
150 ExecStart = utils.escapeSystemdExecArgs [
151 "${cfg.package}/bin/coolwsd-systemplate-setup"
152 "/var/lib/cool/systemplate"
153 "${cfg.package.libreoffice}/lib/collaboraoffice"
155 RemainAfterExit = true;
156 StateDirectory = "cool";
162 systemd.services.coolwsd = {
163 description = "Collabora Online WebSocket Daemon";
164 wantedBy = [ "multi-user.target" ];
167 "coolwsd-systemplate-setup.service"
170 environment = builtins.listToAttrs (
172 name = "aliasgroup${toString n}";
173 value = lib.concatStringsSep "," ([ ag.host ] ++ ag.aliases);
178 ExecStart = utils.escapeSystemdExecArgs (
180 "${cfg.package}/bin/coolwsd"
181 "--config-file=${configFile}"
182 "--port=${toString cfg.port}"
189 KillSignal = "SIGINT";
190 LimitNOFILE = "infinity:infinity";
192 StateDirectory = "cool";
193 TimeoutStopSec = 120;
199 meta.maintainers = [ lib.maintainers.xzfc ];