-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Add Collabora Online #330708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add Collabora Online #330708
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,200 @@ | ||
| { | ||
| config, | ||
| lib, | ||
| pkgs, | ||
| utils, | ||
| ... | ||
| }: | ||
|
|
||
| let | ||
| cfg = config.services.collabora-online; | ||
|
|
||
| freeformType = lib.types.attrsOf ((pkgs.formats.json { }).type) // { | ||
| description = '' | ||
| `coolwsd.xml` configuration type, used to override values in the default configuration. | ||
|
|
||
| Attribute names correspond to XML tags unless prefixed with `@`. Nested attribute sets | ||
| correspond to nested XML tags. Attribute prefixed with `@` correspond to XML attributes. E.g., | ||
| `{ storage.wopi."@allow" = true; }` in Nix corresponds to | ||
| `<storage><wopi allow="true"/></storage>` in `coolwsd.xml`, or `--o:storage.wopi[@allow]=true` | ||
| in the command line. | ||
|
|
||
| Arrays correspond to multiple elements with the same tag name. E.g. | ||
| `{ host = [ '''127\.0\.0\.1''' "::1" ]; }` in Nix corresponds to | ||
| ```xml | ||
| <net><post_allow> | ||
| <host>127\.0\.0\.1</host> | ||
| <host>::1</host> | ||
| </post_allow></net> | ||
| ``` | ||
| in `coolwsd.xml`, or | ||
| `--o:net.post_allow.host[0]='127\.0\.0\.1 --o:net.post_allow.host[1]=::1` in the command line. | ||
|
|
||
| Null values could be used to remove an element from the default configuration. | ||
| ''; | ||
| }; | ||
|
|
||
| configFile = | ||
| pkgs.runCommandLocal "coolwsd.xml" | ||
| { | ||
| nativeBuildInputs = [ | ||
| pkgs.jq | ||
| pkgs.yq-go | ||
| ]; | ||
| userConfig = builtins.toJSON { config = cfg.settings; }; | ||
| passAsFile = [ "userConfig" ]; | ||
| } | ||
| # Merge the cfg.settings into the default coolwsd.xml. | ||
| # See https://github.com/CollaboraOnline/online/issues/10049. | ||
| '' | ||
| yq --input-format=xml \ | ||
| --xml-attribute-prefix=@ \ | ||
| --output-format=json \ | ||
| ${cfg.package}/etc/coolwsd/coolwsd.xml \ | ||
| > ./default_coolwsd.json | ||
|
|
||
| jq '.[0] * .[1] | del(..|nulls)' \ | ||
| --slurp \ | ||
| ./default_coolwsd.json \ | ||
| $userConfigPath \ | ||
| > ./merged.json | ||
|
|
||
| yq --output-format=xml \ | ||
| --xml-attribute-prefix=@ \ | ||
| ./merged.json \ | ||
| > $out | ||
| ''; | ||
| in | ||
| { | ||
| options.services.collabora-online = { | ||
| enable = lib.mkEnableOption "collabora-online"; | ||
|
|
||
| package = lib.mkPackageOption pkgs "Collabora Online" { default = "collabora-online"; }; | ||
|
|
||
| port = lib.mkOption { | ||
| type = lib.types.port; | ||
| default = 9980; | ||
| description = "Listening port"; | ||
| }; | ||
|
|
||
| settings = lib.mkOption { | ||
| type = freeformType; | ||
| default = { }; | ||
| description = '' | ||
| Configuration for Collabora Online WebSocket Daemon, see | ||
| <https://sdk.collaboraonline.com/docs/installation/Configuration.html>, or | ||
| <https://github.com/CollaboraOnline/online/blob/master/coolwsd.xml.in> for the default | ||
| configuration. | ||
| ''; | ||
| }; | ||
|
|
||
| aliasGroups = lib.mkOption { | ||
| type = lib.types.listOf ( | ||
| lib.types.submodule { | ||
| options = { | ||
| host = lib.mkOption { | ||
| type = lib.types.str; | ||
| example = "scheme://hostname:port"; | ||
| description = "Hostname to allow or deny."; | ||
| }; | ||
|
|
||
| aliases = lib.mkOption { | ||
| type = lib.types.listOf lib.types.str; | ||
| default = [ ]; | ||
| example = [ | ||
| "scheme://aliasname1:port" | ||
| "scheme://aliasname2:port" | ||
| ]; | ||
| description = "A list of regex pattern of aliasname."; | ||
| }; | ||
| }; | ||
| } | ||
| ); | ||
| default = [ ]; | ||
| description = "Alias groups to use."; | ||
| }; | ||
|
|
||
| extraArgs = lib.mkOption { | ||
| type = lib.types.listOf lib.types.str; | ||
| default = [ ]; | ||
| description = "Extra arguments to pass to the service."; | ||
| }; | ||
| }; | ||
|
|
||
| config = lib.mkIf cfg.enable { | ||
| services.collabora-online.settings = { | ||
| child_root_path = lib.mkDefault "/var/lib/cool/child-roots"; | ||
| sys_template_path = lib.mkDefault "/var/lib/cool/systemplate"; | ||
|
|
||
| file_server_root_path = lib.mkDefault "${config.services.collabora-online.package}/share/coolwsd"; | ||
|
|
||
| # Use mount namespaces instead of setcap'd coolmount/coolforkit. | ||
| mount_namespaces = lib.mkDefault true; | ||
|
|
||
| # By default, use dummy self-signed certificates provided for testing. | ||
| ssl.ca_file_path = lib.mkDefault "${config.services.collabora-online.package}/etc/coolwsd/ca-chain.cert.pem"; | ||
| ssl.cert_file_path = lib.mkDefault "${config.services.collabora-online.package}/etc/coolwsd/cert.pem"; | ||
| ssl.key_file_path = lib.mkDefault "${config.services.collabora-online.package}/etc/coolwsd/key.pem"; | ||
| }; | ||
|
|
||
| users.users.cool = { | ||
| isSystemUser = true; | ||
| group = "cool"; | ||
| }; | ||
| users.groups.cool = { }; | ||
|
|
||
| systemd.services.coolwsd-systemplate-setup = { | ||
| description = "Collabora Online WebSocket Daemon Setup"; | ||
| wantedBy = [ "multi-user.target" ]; | ||
| serviceConfig = { | ||
| ExecStart = utils.escapeSystemdExecArgs [ | ||
| "${cfg.package}/bin/coolwsd-systemplate-setup" | ||
| "/var/lib/cool/systemplate" | ||
| "${cfg.package.libreoffice}/lib/collaboraoffice" | ||
| ]; | ||
| RemainAfterExit = true; | ||
| StateDirectory = "cool"; | ||
| Type = "oneshot"; | ||
| User = "cool"; | ||
| }; | ||
| }; | ||
|
|
||
| systemd.services.coolwsd = { | ||
| description = "Collabora Online WebSocket Daemon"; | ||
| wantedBy = [ "multi-user.target" ]; | ||
| after = [ | ||
| "network.target" | ||
| "coolwsd-systemplate-setup.service" | ||
| ]; | ||
|
|
||
| environment = builtins.listToAttrs ( | ||
| lib.imap1 (n: ag: { | ||
| name = "aliasgroup${toString n}"; | ||
| value = lib.concatStringsSep "," ([ ag.host ] ++ ag.aliases); | ||
| }) cfg.aliasGroups | ||
| ); | ||
|
|
||
| serviceConfig = { | ||
| ExecStart = utils.escapeSystemdExecArgs ( | ||
| [ | ||
| "${cfg.package}/bin/coolwsd" | ||
| "--config-file=${configFile}" | ||
| "--port=${toString cfg.port}" | ||
| "--use-env-vars" | ||
| "--version" | ||
| ] | ||
| ++ cfg.extraArgs | ||
| ); | ||
| KillMode = "mixed"; | ||
| KillSignal = "SIGINT"; | ||
| LimitNOFILE = "infinity:infinity"; | ||
| Restart = "always"; | ||
| StateDirectory = "cool"; | ||
| TimeoutStopSec = 120; | ||
| User = "cool"; | ||
| }; | ||
| }; | ||
| }; | ||
|
|
||
| meta.maintainers = [ lib.maintainers.xzfc ]; | ||
| } | ||
15 changes: 15 additions & 0 deletions
15
pkgs/by-name/co/collabora-online/fix-file-server-regex.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| In the nix build, COOLWSD_VERSION_HASH becomes the same as COOLWSD_VERSION, e.g. | ||
| `24.04.3.5`. The web server that serves files from | ||
| `/browser/$COOLWSD_VERSION_HASH`, doesn't expect the hash to contain dots. | ||
|
|
||
| --- a/wsd/FileServer.cpp | ||
| +++ b/wsd/FileServer.cpp | ||
| @@ -933,7 +933,7 @@ std::string FileServerRequestHandler::getRequestPathname(const HTTPRequest& requ | ||
|
|
||
| std::string path(requestUri.getPath()); | ||
|
|
||
| - Poco::RegularExpression gitHashRe("/([0-9a-f]+)/"); | ||
| + Poco::RegularExpression gitHashRe("/([0-9a-f.]+)/"); | ||
| std::string gitHash; | ||
| if (gitHashRe.extract(path, gitHash)) | ||
| { |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.