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:
parent
ce1ba0e9f3
commit
9e10d73cea
1 changed files with 5 additions and 18 deletions
|
|
@ -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;
|
||||||
);
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue