Use `db` for local database instance.

pull/1/head
Joshua Potter 2023-12-01 11:00:43 -07:00
parent 615509216a
commit c8e138ef68
3 changed files with 17 additions and 20 deletions

2
.gitignore vendored
View File

@ -36,7 +36,7 @@ npm-debug.log
/assets/node_modules/ /assets/node_modules/
# The default location of the generated database cluster. # The default location of the generated database cluster.
/data/ /db/
# Directory used by `direnv` to hold `use flake`-generated profiles. # Directory used by `direnv` to hold `use flake`-generated profiles.
/.direnv/ /.direnv/

View File

@ -5,33 +5,35 @@ This is a template for constructing a environment for Elixir development
(version 1.7.10) framework. [direnv](https://direnv.net/) can be used to launch (version 1.7.10) framework. [direnv](https://direnv.net/) can be used to launch
a dev shell upon entering this directory (refer to `.envrc`). Otherwise run via: a dev shell upon entering this directory (refer to `.envrc`). Otherwise run via:
```bash ```bash
$> nix develop $ nix develop
``` ```
## Quickstart ## Quickstart
An empty Postgres cluster is initialized at `/data`. To start the database, run An empty Postgres cluster is initialized at `/db`. To start the database, run
the following: the following:
```bash ```bash
$> pg_ctl start -o --unix_socket_directories="$PWD/data" $ pg_ctl -D db -l db/logfile -o --unix_socket_directories=@boardwise start
``` ```
To shut the database down, run: In the above command, `@boardwise` refers to an [abstract socket name](https://www.postgresql.org/docs/15/runtime-config-connection.html#GUC-UNIX-SOCKET-DIRECTORIES).
Rename to whatever is appropriate for your use case. To then connect to this
database instance, run:
```bash ```bash
$> pg_ctl stop $ psql -h @boardwise
``` ```
You can connect to this database from the project root directory by running: To later shut the database down, run:
```bash ```bash
$> psql -h "$PWD/data" -d postgres $ pg_ctl -D db stop
``` ```
Afterward, you can run the Phoenix setup commands: Afterward, you can run the Phoenix setup commands:
```bash ```bash
$> mix ecto.setup $ mix ecto.setup
$> mix assets.setup $ mix assets.setup
``` ```
and then start the local server: and then start the local server:
```bash ```bash
$> mix phx.server $ mix phx.server
``` ```
## Dependencies ## Dependencies
@ -39,7 +41,7 @@ $> mix phx.server
This project pins Mix dependencies using [mix2nix](https://github.com/ydlr/mix2nix). This project pins Mix dependencies using [mix2nix](https://github.com/ydlr/mix2nix).
After updating your `mix.lock` file, make sure to re-run the following: After updating your `mix.lock` file, make sure to re-run the following:
```bash ```bash
mix2nix > deps.nix $ mix2nix > deps.nix
``` ```
As of now, `mix2nix` cannot handle git dependencies found inside the `mix.lock` As of now, `mix2nix` cannot handle git dependencies found inside the `mix.lock`
file. If you have git dependencies, add them manually or use file. If you have git dependencies, add them manually or use
@ -56,7 +58,7 @@ Formatting depends on the `mix format` task. A `pre-commit` hook is included in
`.githooks` that can be used to format all `*.exs?` files prior to commit. `.githooks` that can be used to format all `*.exs?` files prior to commit.
Install via: Install via:
```bash ```bash
$> git config --local core.hooksPath .githooks/ $ git config --local core.hooksPath .githooks/
``` ```
If running [direnv](https://direnv.net/), this hook is installed automatically If running [direnv](https://direnv.net/), this hook is installed automatically
when entering the directory. when entering the directory.

View File

@ -1,10 +1,5 @@
{ {
description = '' description = "The BoardWise backend/frontend.";
An opinionated pheonix flake.
To generate a copy of this template elsewhere, run:
$> bootstrap phoenix
'';
inputs = { inputs = {
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"; flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
@ -56,7 +51,7 @@
# environment variable whenever `-D` is not specified (for e.g. # environment variable whenever `-D` is not specified (for e.g.
# `postgres` and `pg_ctl`). # `postgres` and `pg_ctl`).
# https://www.postgresql.org/docs/15/server-start.html # https://www.postgresql.org/docs/15/server-start.html
export PGDATA="$PWD/data" export PGDATA="$PWD/db"
''; '';
}; };
}); });