nix-processmgmt-services/service-containers-agnostic/postgresql/simplepostgresql.nix

46 lines
1.3 KiB
Nix

{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