From 7a2f1c2ba583f82deb1b093dd67ec85bb4c6f76c Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Tue, 5 Sep 2023 17:08:25 +0530 Subject: [PATCH] revert example flake overwrite --- example/flake.nix | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/example/flake.nix b/example/flake.nix index e3073b3b..54068294 100644 --- a/example/flake.nix +++ b/example/flake.nix @@ -26,8 +26,43 @@ imports = [ inputs.services-flake.processComposeModules.default ]; - services.mysql.m1.enable = true; + services.postgres."pg1" = { + enable = true; + listen_addresses = "127.0.0.1"; + initialDatabases = [ + { + name = dbName; + schema = "${inputs.northwind}/northwind.sql"; + } + ]; + }; + + services.postgres."pg2" = { + enable = true; + listen_addresses = "127.0.0.1"; + port = 5433; + }; + + settings.processes.pgweb = + let + pgcfg = config.services.postgres.pg1; + in + { + environment.PGWEB_DATABASE_URL = "postgres://$USER@${pgcfg.listen_addresses}:${builtins.toString pgcfg.port}/${dbName}"; + command = pkgs.pgweb; + depends_on."pg1".condition = "process_healthy"; + }; + settings.processes.test = { + command = pkgs.writeShellApplication { + name = "pg1-test"; + runtimeInputs = [ config.services.postgres.pg1.package ]; + text = '' + echo 'SELECT version();' | psql -h 127.0.0.1 ${dbName} + ''; + }; + depends_on."pg1".condition = "process_healthy"; + }; }; devShells.default = pkgs.mkShell {