fix script

This commit is contained in:
2025-03-17 13:17:50 +04:00
parent 4947fd35b5
commit 3b67a7ab1c

19
lib.nix
View File

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