diff --git a/devsupport/.gitignore b/devsupport/.gitignore new file mode 100644 index 0000000..d44a8fa --- /dev/null +++ b/devsupport/.gitignore @@ -0,0 +1,3 @@ +db/ +db_sockets/ +!db_sockets/.gitkeep diff --git a/devsupport/db_sockets/.gitkeep b/devsupport/db_sockets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/devsupport/run_postgres.sh b/devsupport/run_postgres.sh new file mode 100755 index 0000000..75a0ebb --- /dev/null +++ b/devsupport/run_postgres.sh @@ -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" diff --git a/devsupport/setup_postgres.sh b/devsupport/setup_postgres.sh new file mode 100755 index 0000000..a9a5ef3 --- /dev/null +++ b/devsupport/setup_postgres.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +sqlx database create +sqlx migrate run diff --git a/envrc.example b/envrc.example new file mode 100644 index 0000000..5ab056f --- /dev/null +++ b/envrc.example @@ -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 diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..d3d0f8a --- /dev/null +++ b/flake.lock @@ -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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..69dc398 --- /dev/null +++ b/flake.nix @@ -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}; + }); +}