2021-03-03 19:19:00 +00:00
|
|
|
{postgresqlConstructorFun, lib, dysnomia, runtimeDir}:
|
2020-11-04 20:42:57 +00:00
|
|
|
|
|
|
|
{ instanceSuffix ? "", instanceName ? "postgresql${instanceSuffix}"
|
|
|
|
, containerName ? "postgresql-database${instanceSuffix}"
|
|
|
|
, port ? 5432
|
2021-03-03 19:19:00 +00:00
|
|
|
, type ? null
|
2020-11-04 20:42:57 +00:00
|
|
|
, properties ? {}
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
username = instanceName;
|
|
|
|
|
|
|
|
pkg = postgresqlConstructorFun {
|
|
|
|
inherit instanceName instanceSuffix port;
|
|
|
|
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;
|
2023-09-21 22:13:47 +00:00
|
|
|
postgresqlRuntimeDir = "${runtimeDir}/${instanceName}";
|
2020-11-04 20:42:57 +00:00
|
|
|
postgresqlUsername = username;
|
|
|
|
|
2021-03-03 19:19:00 +00:00
|
|
|
inherit pkg;
|
2020-11-04 20:42:57 +00:00
|
|
|
|
|
|
|
providesContainer = containerName;
|
2021-03-03 19:19:00 +00:00
|
|
|
} // lib.optionalAttrs (type != null) {
|
|
|
|
inherit type;
|
2020-11-04 20:42:57 +00:00
|
|
|
} // properties
|