Skip to content

Commit

Permalink
refactor: match with new supabase_potion release
Browse files Browse the repository at this point in the history
  • Loading branch information
zoedsoupe committed Jan 13, 2025
1 parent 2e48e33 commit f83dd1a
Show file tree
Hide file tree
Showing 15 changed files with 377 additions and 332 deletions.
29 changes: 0 additions & 29 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,3 @@ export ERL_AFLAGS="-kernel shell_history enabled"
export LANG=en_US.UTF-8

use flake

# Setup postgresql
if test -d "/Applications/Postgres.app"; then
export DATABASE_USER="$(whoami)"
export DATABASE_PASSWORD=""
else
# postges related
export DATABASE_USER="supabase_potion"
export DATABASE_PASSWORD="supabase_potion"
export PG_DATABASE="supabase_potion_dev"
# keep all your db data in a folder inside the project
export PGHOST="$PWD/.postgres"
export PGDATA="$PGHOST/data"
export PGLOG="$PGHOST/server.log"

if [[ ! -d "$PGDATA" ]]; then
# initital set up of database server
initdb --auth=trust --no-locale --encoding=UTF8 -U=$DATABASE_USER >/dev/null

# point to correct unix sockets
echo "unix_socket_directories = '$PGHOST'" >> "$PGDATA/postgresql.conf"
# creates loacl database user
echo "CREATE USER $DATABASE_USER SUPERUSER;" | postgres --single -E postgres
# creates local databse
echo "CREATE DATABASE $PG_DATABASE;" | postgres --single -E postgres
fi
fi

source .env
3 changes: 1 addition & 2 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Used by "mix format"
[
inputs: ["mix.exs", "config/*.exs"],
subdirectories: ["apps/*"]
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]
63 changes: 5 additions & 58 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 28 additions & 37 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,43 +1,34 @@
{
description = "Supabase SDK for Elixir";
description = "Supabase Storage integration for Elixir";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
systems.url = "github:nix-systems/default";
};
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11-small";

outputs = {nixpkgs, ...}: let
inherit (nixpkgs.lib) genAttrs;
inherit (nixpkgs.lib.systems) flakeExposed;
forAllSystems = f:
genAttrs flakeExposed (system: f (import nixpkgs {inherit system;}));
in {
devShells = forAllSystems (pkgs: let
inherit (pkgs) mkShell;
inherit (pkgs.beam.interpreters) erlang_27;
inherit (pkgs.beam) packagesWith;
beam = packagesWith erlang_27;
elixir_1_18 = beam.elixir.override {
version = "1.18.1";

outputs = {
flake-parts,
systems,
...
} @ inputs:
flake-parts.lib.mkFlake {inherit inputs;} {
systems = import systems;
perSystem = {
pkgs,
system,
...
}: let
inherit (pkgs.beam.interpreters) erlang_27;
inherit (pkgs.beam) packagesWith;
beam = packagesWith erlang_27;
in {
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
config.allowUnfree = true;
src = pkgs.fetchFromGitHub {
owner = "elixir-lang";
repo = "elixir";
rev = "v1.18.1";
sha256 = "sha256-zJNAoyqSj/KdJ1Cqau90QCJihjwHA+HO7nnD1Ugd768=";
};
devShells.default = with pkgs;
mkShell {
name = "storage-ex";
packages = with pkgs;
[beam.elixir_1_17]
++ lib.optional stdenv.isLinux [inotify-tools]
++ lib.optional stdenv.isDarwin [
darwin.apple_sdk.frameworks.CoreServices
darwin.apple_sdk.frameworks.CoreFoundation
];
};
};
};
in {
default = mkShell {
name = "storage-ex";
packages = with pkgs; [elixir_1_18 postgresql];
};
});
};
}
Loading

0 comments on commit f83dd1a

Please sign in to comment.