Integrate mailman3 service into my existing configuration.

This commit is contained in:
Kevin Baensch 2019-07-03 08:38:11 +02:00
parent df12a85010
commit d9ecea0a17
4 changed files with 42 additions and 14 deletions

View file

@ -3,19 +3,23 @@
with lib;
let
giteapwd = if config.services.gitea.enable then (fileContents /secret/gitea) else "";
cfg = config.services;
mkInitialDatabases = servicename: if (cfg."${servicename}".enable && (cfg."${servicename}".database.type == "mysql")) then
let
password = (fileContents "/secret/${servicename}_db");
cfg = config.services."${servicename}".database;
in {
name = cfg.name;
schema = pkgs.writeText "${cfg.name}.sql" ''
create user if not exists ${cfg.user}@'localhost' identified by ${password};
grant all privileges on ${cfg.name}.* to ${cfg.user}@'localhost' identified by ${password};
'';
} else {};
in mkIf (elem "mariaDB" config.machine.services) {
services.mysql = {
enable = true;
package = pkgs.mariadb;
initialDatabases = if config.services.gitea.enable then [ {
name = "gitea";
schema = pkgs.writeText "gitea.sql"
''
create user if not exists 'git'@'localhost' identified by ${giteapwd};
grant all privileges on gitea.* to 'git'@'localhost' identified by ${giteapwd};
'';
} ] else [];
initialDatabases = (map mkInitialDatabases [ "mailman3" "gitea" ]);
};
}