onlyoffice: add module (#6667)

This commit is contained in:
Aguirre Matteo 2025-03-20 13:34:43 -03:00 committed by GitHub
parent 94605dcade
commit c36cc49e55
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 87 additions and 0 deletions

View file

@ -0,0 +1,50 @@
{ lib, pkgs, config, ... }:
let
inherit (lib)
types isBool boolToString concatStringsSep mapAttrsToList mkIf
mkEnableOption mkPackageOption mkOption;
cfg = config.programs.onlyoffice;
attrToString = name: value:
let newvalue = if (isBool value) then (boolToString value) else value;
in "${name}=${newvalue}";
getFinalConfig = set:
(concatStringsSep "\n" (mapAttrsToList attrToString set)) + "\n";
in {
meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ];
options.programs.onlyoffice = {
enable = mkEnableOption "onlyoffice";
package =
mkPackageOption pkgs "onlyoffice-desktopeditors" { nullable = true; };
settings = mkOption {
type = with types; attrsOf (either bool str);
default = { };
example = ''
UITheme = "theme-contrast-dark";
editorWindowMode = false;
forcedRtl = false;
maximized = true;
titlebar = "custom";
'';
description = ''
Configuration settings for Onlyoffice.
All configurable options can be deduced by enabling them through the
GUI and observing the changes in ~/.config/onlyoffice/DesktopEditors.conf.
'';
};
};
config = mkIf cfg.enable {
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."onlyoffice/DesktopEditors.conf".source =
pkgs.writeText "DesktopEditors.conf" (getFinalConfig cfg.settings);
};
}