roles: implement dbserver mariadb and postgresql roles

This commit is contained in:
2025-07-06 12:43:40 -07:00
parent bb632f41f0
commit 2550ed97e6
2 changed files with 81 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
# Module: roles/dbserver-mariadb
# Enables a database server running MariaDB
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.dbserver-mariadb;
defaultDBPackage = mariadb;
defaultPyMySQLPackage = 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 = python313Packages.pymysql;
};
};
config = mkIf config.dbserver-mariadb.enable {
environment.systemPackages = with pkgs; [
cfg.dbPackage
cfg.ansibleLibPackage
];
services.mysql = {
enable = true;
package = cfg.dbPackage;
};
};
}

View File

@@ -0,0 +1,40 @@
# Module: roles/dbserver-postgresql
# Enables a database server running PostgreSQL
with lib;
let
cfg = config.dbserver-postgresql;
defaultPostgresPackage = postgresql;
defaultPsycopg2Package = python313Packages.psycopg2;
in {
options.dbserver-postgresql = {
enable = mkEnableOption "Enables dbserver-postgresql role";
dbPackage = mkOption {
type = types.package;
default = defaultPostgresPackage;
description = "Package to use for the database server";
example = postgresql;
};
ansibleLibPackage = mkOption {
type = types.package;
default = defaultPsycopg2Package;
description = "Python library to use for Ansible interfacing";
example = python313Packages.psycopg2;
};
};
config = mkIf config.dbserver-mariadb.enable {
environment.systemPackages = with pkgs; [
cfg.dbPackage
cfg.ansibleLibPackage
];
services.postgresql = {
enable = true;
package = cfg.dbPackage;
};
};
}