From ab9f56db4c94e4595a103b14f748b9df7944870f Mon Sep 17 00:00:00 2001 From: Arvin Sevilla Date: Thu, 18 Apr 2024 15:32:03 +0800 Subject: [PATCH] docs(phoenix): connect to unix socket instead of tcp issue: https://github.com/cachix/devenv/issues/1088 reference: https://github.com/cachix/devenv/pull/803/files --- examples/phoenix/.test.sh | 2 +- examples/phoenix/README.md | 4 +++- examples/phoenix/devenv.nix | 14 ++++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/examples/phoenix/.test.sh b/examples/phoenix/.test.sh index b3405d8a4..8728f2944 100755 --- a/examples/phoenix/.test.sh +++ b/examples/phoenix/.test.sh @@ -2,7 +2,7 @@ set -ex pushd hello - wait_for_port 4000 + wait_for_port 4000 60 mix ecto.create curl -s http://localhost:4000/ | grep "Phoenix Framework" popd diff --git a/examples/phoenix/README.md b/examples/phoenix/README.md index 5ee416ee6..9c6520d50 100644 --- a/examples/phoenix/README.md +++ b/examples/phoenix/README.md @@ -5,7 +5,9 @@ $ devenv shell $ mix local.hex --force $ mix local.rebar --force $ mix archive.install hex phx_new -$ mix phx.new hello +$ mix phx.new --install hello +$ sed -i.bak -e "s/hostname: \"localhost\"/socket_dir: System.get_env(\"PGHOST\")/" \ + ./hello/config/dev.exs && rm ./hello/config/dev.exs.bak $ devenv up $ cd hello && mix ecto.create ``` diff --git a/examples/phoenix/devenv.nix b/examples/phoenix/devenv.nix index 99b2925d1..204a81177 100644 --- a/examples/phoenix/devenv.nix +++ b/examples/phoenix/devenv.nix @@ -18,11 +18,17 @@ processes.phoenix.exec = "cd hello && mix phx.server"; enterShell = '' + mix local.hex --force + mix local.rebar --force + mix archive.install --force hex phx_new + if [ ! -d "hello" ]; then - mix local.hex --force - mix local.rebar --force - mix archive.install --force hex phx_new - mix phx.new --install hello + # guard against multiple invocation of "enterShell" + mkdir hello + + echo y | mix phx.new --install hello + sed -i.bak -e "s/hostname: \"localhost\"/socket_dir: System.get_env(\"PGHOST\")/" \ + ./hello/config/dev.exs && rm ./hello/config/dev.exs.bak fi ''; }