nixos/onlyoffice: init

Co-authored-by: Emmanuel Rosa <emmanuelrosa@protonmail.com>
This commit is contained in:
Grayson Tinker
2026-10-07 16:15:54 -06:00
parent 151fa4e8dd
commit 3fc4bd2db6
4 changed files with 63 additions and 4 deletions

View File

@@ -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).

View File

@@ -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

View File

@@ -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 ];
}

View File

@@ -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