1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-05 00:21:04 +01:00

onlyoffice: use pkgs.formats and use mkIf in config file generation (#7006)

This commit is contained in:
Aguirre Matteo 2025-05-09 13:20:05 +00:00 committed by GitHub
parent ce1ba0e9f3
commit 9e10d73cea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,11 +7,6 @@
let let
inherit (lib) inherit (lib)
types
isBool
boolToString
concatStringsSep
mapAttrsToList
mkIf mkIf
mkEnableOption mkEnableOption
mkPackageOption mkPackageOption
@ -19,15 +14,7 @@ let
; ;
cfg = config.programs.onlyoffice; cfg = config.programs.onlyoffice;
formatter = pkgs.formats.keyValue { };
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 in
{ {
meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ]; meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ];
@ -38,7 +25,7 @@ in
package = mkPackageOption pkgs "onlyoffice-desktopeditors" { nullable = true; }; package = mkPackageOption pkgs "onlyoffice-desktopeditors" { nullable = true; };
settings = mkOption { settings = mkOption {
type = with types; attrsOf (either bool str); type = formatter.type;
default = { }; default = { };
example = '' example = ''
UITheme = "theme-contrast-dark"; UITheme = "theme-contrast-dark";
@ -59,8 +46,8 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ]; home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."onlyoffice/DesktopEditors.conf".source = pkgs.writeText "DesktopEditors.conf" ( xdg.configFile."onlyoffice/DesktopEditors.conf" = mkIf (cfg.settings != { }) {
getFinalConfig cfg.settings source = formatter.generate "onlyoffice-config" cfg.settings;
); };
}; };
} }