roles: implement dbserver mariadb and postgresql roles
This commit is contained in:
@@ -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;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@@ -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;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user