1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-05 08:31:03 +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
inherit (lib)
types
isBool
boolToString
concatStringsSep
mapAttrsToList
mkIf
mkEnableOption
mkPackageOption
@ -19,15 +14,7 @@ let
;
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";
formatter = pkgs.formats.keyValue { };
in
{
meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ];
@ -38,7 +25,7 @@ in
package = mkPackageOption pkgs "onlyoffice-desktopeditors" { nullable = true; };
settings = mkOption {
type = with types; attrsOf (either bool str);
type = formatter.type;
default = { };
example = ''
UITheme = "theme-contrast-dark";
@ -59,8 +46,8 @@ in
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
);
xdg.configFile."onlyoffice/DesktopEditors.conf" = mkIf (cfg.settings != { }) {
source = formatter.generate "onlyoffice-config" cfg.settings;
};
};
}