nixos/services.ejabberd: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-28 21:19:06 +02:00 committed by Jörg Thalheim
parent e59cdc8e99
commit aa2c039ab0

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.ejabberd;
@ -11,7 +8,7 @@ let
${cfg.ctlConfig}
'';
ectl = ''${cfg.package}/bin/ejabberdctl ${optionalString (cfg.configFile != null) "--config ${cfg.configFile}"} --ctl-config "${ctlcfg}" --spool "${cfg.spoolDir}" --logs "${cfg.logsDir}"'';
ectl = ''${cfg.package}/bin/ejabberdctl ${lib.optionalString (cfg.configFile != null) "--config ${cfg.configFile}"} --ctl-config "${ctlcfg}" --spool "${cfg.spoolDir}" --logs "${cfg.logsDir}"'';
dumps = lib.escapeShellArgs cfg.loadDumps;
@ -23,59 +20,59 @@ in {
services.ejabberd = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to enable ejabberd server";
};
package = mkPackageOption pkgs "ejabberd" { };
package = lib.mkPackageOption pkgs "ejabberd" { };
user = mkOption {
type = types.str;
user = lib.mkOption {
type = lib.types.str;
default = "ejabberd";
description = "User under which ejabberd is ran";
};
group = mkOption {
type = types.str;
group = lib.mkOption {
type = lib.types.str;
default = "ejabberd";
description = "Group under which ejabberd is ran";
};
spoolDir = mkOption {
type = types.path;
spoolDir = lib.mkOption {
type = lib.types.path;
default = "/var/lib/ejabberd";
description = "Location of the spooldir of ejabberd";
};
logsDir = mkOption {
type = types.path;
logsDir = lib.mkOption {
type = lib.types.path;
default = "/var/log/ejabberd";
description = "Location of the logfile directory of ejabberd";
};
configFile = mkOption {
type = types.nullOr types.path;
configFile = lib.mkOption {
type = lib.types.nullOr lib.types.path;
description = "Configuration file for ejabberd in YAML format";
default = null;
};
ctlConfig = mkOption {
type = types.lines;
ctlConfig = lib.mkOption {
type = lib.types.lines;
default = "";
description = "Configuration of ejabberdctl";
};
loadDumps = mkOption {
type = types.listOf types.path;
loadDumps = lib.mkOption {
type = lib.types.listOf lib.types.path;
default = [];
description = "Configuration dumps that should be loaded on the first startup";
example = literalExpression "[ ./myejabberd.dump ]";
example = lib.literalExpression "[ ./myejabberd.dump ]";
};
imagemagick = mkOption {
type = types.bool;
imagemagick = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Add ImageMagick to server's path; allows for image thumbnailing";
};
@ -86,10 +83,10 @@ in {
###### implementation
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
users.users = optionalAttrs (cfg.user == "ejabberd") {
users.users = lib.optionalAttrs (cfg.user == "ejabberd") {
ejabberd = {
group = cfg.group;
home = cfg.spoolDir;
@ -98,7 +95,7 @@ in {
};
};
users.groups = optionalAttrs (cfg.group == "ejabberd") {
users.groups = lib.optionalAttrs (cfg.group == "ejabberd") {
ejabberd.gid = config.ids.gids.ejabberd;
};