nixos/services/mariaDB.nix

22 lines
584 B
Nix
Raw Normal View History

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