Files
nix-config/nas-apps/mariadb.nix
2024-02-24 23:08:52 -06:00

91 lines
1.8 KiB
Nix

{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.nas-apps.mariadb;
in {
options.nas-apps.mariadb = {
enable = mkEnableOption "mariadb docker service";
autoStart = mkOption {
type = types.bool;
default = true;
};
port = mkOption {
type = types.str;
default = "3306";
};
name = mkOption {
type = types.str;
default = "mariadb";
};
image = mkOption {
type = types.str;
default = "linuxserver/mariadb";
};
configPath = mkOption {
type = types.str;
default = "/mnt/ssd/mariadb";
};
puid = mkOption {
type = types.str;
default = "911";
};
pgid = mkOption {
type = types.str;
default = "1000";
};
timeZone = mkOption {
type = types.str;
default = "America/Chicago";
};
rootPassword = mkOption {
type = types.str;
default = "BogieDudie1";
};
databaseName = mkOption {
type = types.str;
default = "jallen_nextcloud";
};
databaseUser = mkOption {
type = types.str;
default = "nextcloud";
};
databasePassword = mkOption {
type = types.str;
default = "BogieDudie1";
};
};
config = mkIf cfg.enable {
virtualisation.oci-containers.containers."${cfg.name}" = {
autoStart = cfg.autoStart;
image = cfg.image;
ports = [ "${cfg.port}:3306" ];
volumes = [
"${cfg.configPath}:/config"
];
environment = {
PUID = cfg.puid;
PGID = cfg.pgid;
TZ = cfg.timeZone;
MYSQL_ROOT_PASSWORD = cfg.rootPassword;
MYSQL_DATABASE = cfg.databaseName;
MYSQL_USER = cfg.databaseUser;
MYSQL_PASSWORD = cfg.databasePassword;
};
};
};
}