Add environment variable option
This commit is contained in:
parent
7cb81b595e
commit
9a0a2be3a1
|
@ -162,6 +162,12 @@ in {
|
||||||
default = 3000;
|
default = 3000;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
environment = mkOption {
|
||||||
|
type = attrsOf str;
|
||||||
|
description = "Environment variables to set for the Mastodon job.";
|
||||||
|
default = { };
|
||||||
|
};
|
||||||
|
|
||||||
smtp = {
|
smtp = {
|
||||||
server = mkOption {
|
server = mkOption {
|
||||||
type = str;
|
type = str;
|
||||||
|
@ -238,12 +244,12 @@ in {
|
||||||
target-file = "/run/mastodon/postgres.env";
|
target-file = "/run/mastodon/postgres.env";
|
||||||
};
|
};
|
||||||
mastodonEnv = {
|
mastodonEnv = {
|
||||||
source-file = makeEnvFile {
|
source-file = makeEnvFile ({
|
||||||
DB_HOST = "postgres";
|
DB_HOST = "postgres";
|
||||||
DB_USER = "mastodon";
|
DB_USER = "mastodon";
|
||||||
DB_NAME = "mastodon";
|
DB_NAME = "mastodon";
|
||||||
DB_PASS = databasePasswd;
|
DB_PASS = databasePasswd;
|
||||||
};
|
}) // cfg.environment;
|
||||||
target-file = "/run/mastodon/mastodon.env";
|
target-file = "/run/mastodon/mastodon.env";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -259,10 +265,6 @@ in {
|
||||||
mkUserMap = uid: "${toString uid}:${toString uid}";
|
mkUserMap = uid: "${toString uid}:${toString uid}";
|
||||||
image = { pkgs, ... }: {
|
image = { pkgs, ... }: {
|
||||||
project.name = "mastodon";
|
project.name = "mastodon";
|
||||||
networks = {
|
|
||||||
internal_network.internal = true;
|
|
||||||
external_network.internal = false;
|
|
||||||
};
|
|
||||||
services = {
|
services = {
|
||||||
proxy.service = {
|
proxy.service = {
|
||||||
image = cfg.images.nginx;
|
image = cfg.images.nginx;
|
||||||
|
@ -270,7 +272,6 @@ in {
|
||||||
ports = [ "${toString cfg.port}:3000" ];
|
ports = [ "${toString cfg.port}:3000" ];
|
||||||
volumes = [ "${proxyConf}:/etc/nginx/nginx.conf:ro,Z" ];
|
volumes = [ "${proxyConf}:/etc/nginx/nginx.conf:ro,Z" ];
|
||||||
depends_on = [ "web" "streaming" ];
|
depends_on = [ "web" "streaming" ];
|
||||||
networks = [ "internal_network" "external_network" ];
|
|
||||||
};
|
};
|
||||||
postgres.service = {
|
postgres.service = {
|
||||||
image = cfg.images.postgres;
|
image = cfg.images.postgres;
|
||||||
|
@ -279,7 +280,6 @@ in {
|
||||||
[ "${cfg.state-directory}/postgres:/var/lib/postgresql/data" ];
|
[ "${cfg.state-directory}/postgres:/var/lib/postgresql/data" ];
|
||||||
healthcheck.test = [ "CMD" "pg_isready" "-U" "postgres" ];
|
healthcheck.test = [ "CMD" "pg_isready" "-U" "postgres" ];
|
||||||
# environment.POSTGRES_HOST_AUTH_METHOD = "trust";
|
# environment.POSTGRES_HOST_AUTH_METHOD = "trust";
|
||||||
networks = [ "internal_network" ];
|
|
||||||
user = mkUserMap cfg.uids.postgres;
|
user = mkUserMap cfg.uids.postgres;
|
||||||
env_file = [
|
env_file = [
|
||||||
hostSecrets.mastodonCommonEnv.target-file
|
hostSecrets.mastodonCommonEnv.target-file
|
||||||
|
@ -291,7 +291,6 @@ in {
|
||||||
restart = "always";
|
restart = "always";
|
||||||
volumes = [ "${cfg.state-directory}/redis:/data" ];
|
volumes = [ "${cfg.state-directory}/redis:/data" ];
|
||||||
healthcheck.test = [ "CMD" "redis-cli" "ping" ];
|
healthcheck.test = [ "CMD" "redis-cli" "ping" ];
|
||||||
networks = [ "internal_network" ];
|
|
||||||
user = mkUserMap cfg.uids.redis;
|
user = mkUserMap cfg.uids.redis;
|
||||||
env_file = [ hostSecrets.mastodonCommonEnv.target-file ];
|
env_file = [ hostSecrets.mastodonCommonEnv.target-file ];
|
||||||
};
|
};
|
||||||
|
@ -309,7 +308,6 @@ in {
|
||||||
"wget -q --spider --proxy=off localhost:3000/health || exit 1"
|
"wget -q --spider --proxy=off localhost:3000/health || exit 1"
|
||||||
];
|
];
|
||||||
depends_on = [ "postgres" "redis" ];
|
depends_on = [ "postgres" "redis" ];
|
||||||
networks = [ "internal_network" ];
|
|
||||||
user = mkUserMap cfg.uids.mastodon;
|
user = mkUserMap cfg.uids.mastodon;
|
||||||
env_file = [
|
env_file = [
|
||||||
hostSecrets.mastodonCommonEnv.target-file
|
hostSecrets.mastodonCommonEnv.target-file
|
||||||
|
|
Loading…
Reference in New Issue