From 8639182fa40a55e70ce03a243ad9f5b366afc7a5 Mon Sep 17 00:00:00 2001 From: Sander van der Burg Date: Fri, 22 Sep 2023 00:13:47 +0200 Subject: [PATCH] Add container service for the simple PostgreSQL variant --- service-containers-agnostic/constructors.nix | 9 ++++ .../postgresql/default.nix | 1 + .../postgresql/simplepostgresql.nix | 45 +++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 service-containers-agnostic/postgresql/simplepostgresql.nix diff --git a/service-containers-agnostic/constructors.nix b/service-containers-agnostic/constructors.nix index 1b8eaa7..5ba1c95 100644 --- a/service-containers-agnostic/constructors.nix +++ b/service-containers-agnostic/constructors.nix @@ -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; diff --git a/service-containers-agnostic/postgresql/default.nix b/service-containers-agnostic/postgresql/default.nix index 6eb9b2f..eb60705 100644 --- a/service-containers-agnostic/postgresql/default.nix +++ b/service-containers-agnostic/postgresql/default.nix @@ -30,6 +30,7 @@ in rec { name = instanceName; postgresqlPort = port; + postgresqlRuntimeDir = "${runtimeDir}/${instanceName}"; postgresqlUsername = username; inherit pkg; diff --git a/service-containers-agnostic/postgresql/simplepostgresql.nix b/service-containers-agnostic/postgresql/simplepostgresql.nix new file mode 100644 index 0000000..1aa9412 --- /dev/null +++ b/service-containers-agnostic/postgresql/simplepostgresql.nix @@ -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} <