Files
nixos/roles/dbserver-mariadb.nix

48 lines
989 B
Nix

# Module: roles/dbserver-mariadb
# Enables a database server running MariaDB
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.dbserver-mariadb;
defaultDBPackage = pkgs.mariadb;
defaultPyMySQLPackage = pkgs.python313Packages.pymysql;
in
{
options.dbserver-mariadb = {
enable = mkEnableOption "Enables dbserver-mariadb role";
dbPackage = mkOption {
type = types.package;
default = defaultDBPackage;
description = "Package to use for the database server";
example = mariadb;
};
ansibleLibPackage = mkOption {
type = types.package;
default = defaultPyMySQLPackage;
description = "Python library to use for Ansible interfacing";
example = pkgs.python313Packages.pymysql;
};
};
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
cfg.dbPackage
cfg.ansibleLibPackage
];
services.mysql = {
enable = true;
package = cfg.dbPackage;
};
};
}