Add container service for the simple PostgreSQL variant

This commit is contained in:
Sander van der Burg 2023-09-22 00:13:47 +02:00
parent 479afcda26
commit 8639182fa4
3 changed files with 55 additions and 0 deletions

View File

@ -89,6 +89,15 @@ in
});
};
simplePostgresql = import ./postgresql/simplepostgresql.nix {
inherit runtimeDir;
inherit (pkgs) lib;
postgresqlConstructorFun = constructors.simplePostgresql;
dysnomia = pkgs.dysnomia.override (origArgs: {
enablePostgreSQLDatabase = true;
});
};
extendableSupervisord = import ./supervisord/extendable.nix {
inherit libDir;
inherit (pkgs) lib;

View File

@ -30,6 +30,7 @@ in
rec {
name = instanceName;
postgresqlPort = port;
postgresqlRuntimeDir = "${runtimeDir}/${instanceName}";
postgresqlUsername = username;
inherit pkg;

View File

@ -0,0 +1,45 @@
{postgresqlConstructorFun, lib, dysnomia, runtimeDir}:
{ instanceSuffix ? "", instanceName ? "postgresql${instanceSuffix}"
, containerName ? "postgresql-database${instanceSuffix}"
, port ? 5432
, authentication ? null
, identMap ? null
, enableTCPIP ? false
, settings ? {}
, type ? null
, properties ? {}
}:
let
username = instanceName;
pkg = postgresqlConstructorFun {
inherit instanceName instanceSuffix port authentication identMap enableTCPIP settings;
postInstall = ''
# Add Dysnomia container configuration file for PostgreSQL
mkdir -p $out/etc/dysnomia/containers
cat > $out/etc/dysnomia/containers/${containerName} <<EOF
postgresqlPort=${toString port}
postgresqlRuntimeDir=${runtimeDir}/${instanceName}
postgresqlUsername=${username}
EOF
# Copy the Dysnomia module that manages a PostgreSQL database
mkdir -p $out/libexec/dysnomia
ln -s ${dysnomia}/libexec/dysnomia/postgresql-database $out/libexec/dysnomia
'';
};
in
rec {
name = instanceName;
postgresqlPort = port;
postgresqlRuntimeDir = "${runtimeDir}/${instanceName}";
postgresqlUsername = username;
inherit pkg;
providesContainer = containerName;
} // lib.optionalAttrs (type != null) {
inherit type;
} // properties