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 ''; }