mkModule various
This commit is contained in:
@@ -6,26 +6,32 @@
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.${namespace}.services.mongodb;
|
||||
in
|
||||
{
|
||||
imports = [ ./options.nix ];
|
||||
name = "mongodb";
|
||||
cfg = config.${namespace}.services.${name};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
virtualisation.oci-containers.containers."${cfg.name}" = {
|
||||
autoStart = cfg.autoStart;
|
||||
image = cfg.image;
|
||||
ports = [ "${cfg.port}:27017" ];
|
||||
volumes = [ "${cfg.configPath}:/data/db" ];
|
||||
extraOptions = [ "--network-alias=mongo" ];
|
||||
# environmentFiles = cfg.environmentFiles;
|
||||
environment = {
|
||||
PUID = cfg.puid;
|
||||
PGID = cfg.pgid;
|
||||
TZ = cfg.timeZone;
|
||||
# MONGO_INITDB_ROOT_USERNAME = "";#cfg.databaseUser;
|
||||
# MONGO_INITDB_ROOT_PASSWORD = "";#cfg.databasePassword; # get from env file
|
||||
mongodbConfig = lib.${namespace}.mkModule {
|
||||
inherit config name;
|
||||
description = "mongodb";
|
||||
options = { };
|
||||
moduleConfig = {
|
||||
virtualisation.oci-containers.containers."${cfg.name}" = {
|
||||
autoStart = true;
|
||||
image = "mongo";
|
||||
ports = [ "${cfg.port}:27017" ];
|
||||
volumes = [ "${cfg.configPath}/mongodb:/data/db" ];
|
||||
extraOptions = [ "--network-alias=mongo" ];
|
||||
# environmentFiles = cfg.environmentFiles;
|
||||
environment = {
|
||||
PUID = cfg.puid;
|
||||
PGID = cfg.pgid;
|
||||
TZ = cfg.timeZone;
|
||||
# MONGO_INITDB_ROOT_USERNAME = "";#cfg.databaseUser;
|
||||
# MONGO_INITDB_ROOT_PASSWORD = "";#cfg.databasePassword; # get from env file
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [ mongodbConfig ];
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
{ lib, namespace, ... }:
|
||||
with lib;
|
||||
{
|
||||
options.${namespace}.services.mongodb = {
|
||||
enable = mkEnableOption "mongodb docker service";
|
||||
|
||||
autoStart = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
type = types.str;
|
||||
default = "27017";
|
||||
};
|
||||
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
default = "mongo";
|
||||
};
|
||||
|
||||
image = mkOption {
|
||||
type = types.str;
|
||||
default = "mongo";
|
||||
};
|
||||
|
||||
configPath = mkOption {
|
||||
type = types.str;
|
||||
default = "/media/nas/main/mongodb";
|
||||
};
|
||||
|
||||
puid = mkOption {
|
||||
type = types.str;
|
||||
default = "911";
|
||||
};
|
||||
|
||||
pgid = mkOption {
|
||||
type = types.str;
|
||||
default = "1000";
|
||||
};
|
||||
|
||||
timeZone = mkOption {
|
||||
type = types.str;
|
||||
default = "America/Chicago";
|
||||
};
|
||||
|
||||
environmentFiles = mkOption {
|
||||
type = with types; listOf path;
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user