2019-03-20 02:57:59 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
2019-02-26 13:44:40 +01:00
|
|
|
|
|
|
|
let
|
2019-04-14 18:35:37 +02:00
|
|
|
giteapwd = if config.services.gitea.enable then (fileContents /secret/gitea) else "";
|
2019-03-20 02:57:59 +01:00
|
|
|
in mkIf (elem "mariaDB" config.machine.services) {
|
2019-02-26 13:44:40 +01:00
|
|
|
services.mysql = {
|
|
|
|
enable = true;
|
|
|
|
package = pkgs.mariadb;
|
2019-03-20 04:37:00 +01:00
|
|
|
initialDatabases = if config.services.gitea.enable then [ {
|
2019-02-26 13:44:40 +01:00
|
|
|
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};
|
|
|
|
'';
|
2019-03-20 04:37:00 +01:00
|
|
|
} ] else [];
|
2019-02-26 13:44:40 +01:00
|
|
|
};
|
|
|
|
}
|
2019-03-20 02:57:59 +01:00
|
|
|
|