fix(dev): add development workspace support

This commit is contained in:
Judson Lester 2024-09-16 12:13:46 -07:00
parent 387b301656
commit 8bc74e282a
No known key found for this signature in database
GPG key ID: 12E21E4B9A3F82AA
7 changed files with 119 additions and 0 deletions

3
devsupport/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
db/
db_sockets/
!db_sockets/.gitkeep

View file

8
devsupport/run_postgres.sh Executable file
View file

@ -0,0 +1,8 @@
#! /usr/bin/env bash
set -e
devsupport=$(realpath $(dirname $0))
if [ ! -d "$PGDATA" ]; then
initdb --no-instructions
fi
exec postgres -c listen_addresses= -c unix_socket_directories="${devsupport}/db_sockets"

4
devsupport/setup_postgres.sh Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env bash
sqlx database create
sqlx migrate run

7
envrc.example Normal file
View file

@ -0,0 +1,7 @@
export db_socket_path=$(echo $(pwd)/devsupport/db_sockets)
export PGDATA="$(pwd)/devsupport/db"
export DATABASE_URL="postgres:///sqlxmq?host=$db_socket_path&sslmode=disable"
# export SQLX_OFFLINE=yes
session_name sqlxmq
use lorri

61
flake.lock Normal file
View file

@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1717179513,
"narHash": "sha256-vboIEwIQojofItm2xGCdZCzW96U85l9nDW3ifMuAIdM=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "63dacb46bf939521bdc93981b4cbb7ecb58427a0",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

36
flake.nix Normal file
View file

@ -0,0 +1,36 @@
{
description = "sqlxmq is a message queue built by Diggsey on rust sqlx";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/24.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = (import "${nixpkgs}" {
inherit system;
});
runDeps = with pkgs; [
openssl
];
buildDeps = with pkgs; [
pkg-config
] ++ runDeps;
in rec {
devShells.devShell.${system} = pkgs.mkShell {
buildInputs = with pkgs; [
cargo
cargo-expand
rustc
rust-analyzer
clippy
postgresql
sqlx-cli
] ++ buildDeps;
};
devShells.default = devShells.devShell.${system};
});
}