From 3fc4bd2db659d3f571900880e22bd77bfa572990 Mon Sep 17 00:00:00 2001 From: Grayson Tinker Date: Wed, 7 Oct 2026 16:15:54 -0600 Subject: [PATCH] nixos/onlyoffice: init Co-authored-by: Emmanuel Rosa --- .../manual/release-notes/rl-2611.section.md | 2 + nixos/modules/module-list.nix | 1 + nixos/modules/programs/onlyoffice.nix | 37 +++++++++++++++++++ .../on/onlyoffice-desktopeditors/package.nix | 27 ++++++++++++-- 4 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 nixos/modules/programs/onlyoffice.nix diff --git a/nixos/doc/manual/release-notes/rl-2611.section.md b/nixos/doc/manual/release-notes/rl-2611.section.md index 497f42865e11c..411a0ceb2ec46 100644 --- a/nixos/doc/manual/release-notes/rl-2611.section.md +++ b/nixos/doc/manual/release-notes/rl-2611.section.md @@ -58,6 +58,8 @@ - [Watt](https://github.com/NotAShelf/watt), a CPU frequency and power management daemon for Linux. Available as [services.watt](#opt-services.watt.enable). +- [OnlyOffice](https://www.onlyoffice.com), a free and open-source office suite. Available as [programs.onlyoffice](#opt-programs.onlyoffice.enable). + - [mail-tlsa-check-exporter](https://github.com/ietf-tools/mail-tlsa-check-exporter), validates SMTP / IMAP server certificates against a TLSA record as a Prometheus exporter. Available as [services.prometheus.exporters.mail-tlsa-check](#opt-services.prometheus.exporters.mail-tlsa-check.enable). - [snowflake-prometheus-exporter](https://github.com/grafana/snowflake-prometheus-exporter), a Prometheus exporter for Snowflake metrics. Available as [services.prometheus.exporters.snowflake](#opt-services.prometheus.exporters.snowflake.enable). diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 330103917c7ee..5b8483675f169 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -302,6 +302,7 @@ ./programs/oblogout.nix ./programs/obs-studio.nix ./programs/oddjobd.nix + ./programs/onlyoffice.nix ./programs/opengamepadui.nix ./programs/openvpn3.nix ./programs/partition-manager.nix diff --git a/nixos/modules/programs/onlyoffice.nix b/nixos/modules/programs/onlyoffice.nix new file mode 100644 index 0000000000000..d5cf542ed3688 --- /dev/null +++ b/nixos/modules/programs/onlyoffice.nix @@ -0,0 +1,37 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.programs.onlyoffice; +in +{ + options.programs.onlyoffice = { + enable = lib.mkEnableOption "ONLYOFFICE Desktop Editors, an open-source office suite"; + + package = lib.mkPackageOption pkgs "onlyoffice-desktopeditors" { }; + + extraFontPackages = lib.mkOption { + type = lib.types.listOf lib.types.package; + default = config.fonts.packages; + defaultText = lib.literalExpression "config.fonts.packages"; + example = lib.literalExpression "config.fonts.packages ++ [ pkgs.nanum pkgs.liberation_ttf ]"; + description = "Additional fonts to include with onlyoffice."; + }; + }; + + config = + let + package = cfg.package.override { + inherit (cfg) extraFontPackages; + }; + in + lib.mkIf cfg.enable { + environment.systemPackages = [ package ]; + }; + + meta.maintainers = with lib.maintainers; [ graysontinker ]; +} diff --git a/pkgs/by-name/on/onlyoffice-desktopeditors/package.nix b/pkgs/by-name/on/onlyoffice-desktopeditors/package.nix index 482374cbdd0d0..862a66723e54d 100644 --- a/pkgs/by-name/on/onlyoffice-desktopeditors/package.nix +++ b/pkgs/by-name/on/onlyoffice-desktopeditors/package.nix @@ -3,6 +3,9 @@ lib, fetchurl, buildFHSEnv, + symlinkJoin, + runCommand, + extraFontPackages ? [ ], # Alphabetic ordering below alsa-lib, at-spi2-atk, @@ -65,8 +68,21 @@ let # into `~/.local/share/fonts/`, otherwise the default template fonts, and # things like bullet points, will not look as expected. - # TODO: Find out which of these fonts we'd be allowed to distribute along - # with this package, or how to make this easier for users otherwise. + fonts = symlinkJoin { + name = "onlyoffice-fonts"; + paths = [ noto-fonts-cjk-sans ] ++ extraFontPackages; + }; + + # OnlyOffice doesn't follow symlinks, so we have to copy them over. + # https://github.com/ONLYOFFICE/DocumentServer/issues/1859 + fontsDir = runCommand "onlyoffice-fonts-dir" { } '' + font_regexp='.*\.\(ttf\|ttc\|otf\)?' + mkdir -p $out + + find ${fonts} -type l -iregex "$font_regexp" -print0 | while IFS= read -r -d "" file; do + cp -L --update=none "$file" $out/ + done + ''; runtimeLibs = lib.makeLibraryPath [ curl @@ -172,18 +188,21 @@ in # In order to download plugins, OnlyOffice uses /usr/bin/curl so we have to wrap it. # Curl still needs to be in runtimeLibs because the library is used directly in other parts of the code. -# Fonts are also discovered by looking in /usr/share/fonts, so adding fonts to targetPkgs will include them buildFHSEnv { inherit (derivation) pname version; targetPkgs = pkgs': [ curl derivation - noto-fonts-cjk-sans ]; runScript = "/bin/onlyoffice-desktopeditors"; + extraBuildCommands = '' + mkdir -p $out/usr/share + ln -s ${fontsDir} $out/usr/share/fonts + ''; + extraInstallCommands = '' mkdir -p $out/share ln -s ${derivation}/share/icons $out/share