fix script
This commit is contained in:
19
lib.nix
19
lib.nix
@@ -1,8 +1,7 @@
|
||||
{ pkgs }:
|
||||
let
|
||||
inherit (pkgs) lib;
|
||||
pwd = pkgs.runCommand "pwd" { } "realpath .compose>$out";
|
||||
runtime = builtins.readFile pwd;
|
||||
runtime = ".compose";
|
||||
in
|
||||
{
|
||||
mkWrapper =
|
||||
@@ -56,8 +55,7 @@ in
|
||||
pkgs.writeShellApplication {
|
||||
inherit name;
|
||||
text = ''
|
||||
PC_CONFIG_FILES=${configFile} ${pkgs.process-compose}/bin/process-compose "$@"
|
||||
|
||||
PC_CONFIG_FILES=${configFile} RUNTIME_PATH=$(pwd)/${runtime} ${pkgs.process-compose}/bin/process-compose "$@"
|
||||
'';
|
||||
};
|
||||
mkPostgres =
|
||||
@@ -72,9 +70,6 @@ in
|
||||
...
|
||||
}:
|
||||
let
|
||||
|
||||
runtimeDir = "${runtime}/${name}";
|
||||
data_dir = "${runtimeDir}/data";
|
||||
merged_config =
|
||||
(
|
||||
if default_config then
|
||||
@@ -91,7 +86,7 @@ in
|
||||
)
|
||||
// config
|
||||
// {
|
||||
unix_socket_directories = data_dir;
|
||||
unix_socket_directories = "../socket";
|
||||
inherit port listen_addresses;
|
||||
};
|
||||
toStr =
|
||||
@@ -128,7 +123,7 @@ in
|
||||
echo
|
||||
echo "PostgreSQL is setting up the initial database"
|
||||
echo
|
||||
pg_ctl -w start -o "-c unix_socket_directories=$(realpath ${runtimeDir}) -c listen_addresses= -p ${builtins.toString port}"
|
||||
pg_ctl -w start -o "-c unix_socket_directories=$PGHOST -c listen_addresses= -p ${builtins.toString port}"
|
||||
pg_ctl -m fast -w stop
|
||||
else
|
||||
echo
|
||||
@@ -143,11 +138,11 @@ in
|
||||
name = "run-postgres";
|
||||
text = ''
|
||||
set -euo pipefail
|
||||
mkdir -p ${lib.escapeShellArg runtimeDir}
|
||||
|
||||
PGDATA=${data_dir}
|
||||
PGHOST=${runtimeDir}
|
||||
PGDATA=$RUNTIME_PATH/${name}/data
|
||||
PGHOST=$RUNTIME_PATH/${name}/socket
|
||||
PGPORT=${builtins.toString port}
|
||||
mkdir -p $PGHOST
|
||||
echo "Starting postgres with PGDATA=''${PGDATA} PGHOST=''${PGHOST} PGPORT=''${PGPORT}"
|
||||
export PGDATA PGHOST PGPORT
|
||||
${setupScript}/bin/setup-postgres
|
||||
|
||||
Reference in New Issue
Block a user