From 2812f930ac82d878acaf825c5137ba99aadef8a7 Mon Sep 17 00:00:00 2001 From: Zoey de Souza Pessanha Date: Sun, 21 Apr 2024 18:00:13 -0300 Subject: [PATCH] upgrade elixir --- .envrc | 27 -------------------- flake.lock | 67 +++++++++++++++++++++++++++++++++++++++++++++----- flake.nix | 72 ++++++++++++++++++++++++++++-------------------------- 3 files changed, 99 insertions(+), 67 deletions(-) diff --git a/.envrc b/.envrc index dea5ba3..fd16aa2 100644 --- a/.envrc +++ b/.envrc @@ -10,31 +10,4 @@ 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 diff --git a/flake.lock b/flake.lock index 4321d7f..cd953c6 100644 --- a/flake.lock +++ b/flake.lock @@ -1,22 +1,77 @@ { "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1712014858, + "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1704842529, - "narHash": "sha256-OTeQA+F8d/Evad33JMfuXC89VMetQbsU4qcaePchGr4=", + "lastModified": 1713564160, + "narHash": "sha256-YguPZpiejgzLEcO36/SZULjJQ55iWcjAmf3lYiyV1Fo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "bc194f70731cc5d2b046a6c1b3b15f170f05999c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1711703276, + "narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "eabe8d3eface69f5bb16c18f8662a702f50c20d5", + "rev": "d8fe5e6c92d0d190646fb9f1056741a229980089", "type": "github" }, "original": { - "id": "nixpkgs", - "type": "indirect" + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" } }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "systems": "systems" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 019feeb..2941d2c 100644 --- a/flake.nix +++ b/flake.nix @@ -1,39 +1,43 @@ { - description = "A complete Supabase SDK for Elixir alchemists"; + description = "Supabase GoTrue SDK for Elixir"; - outputs = {nixpkgs, ...}: let - for-all-systems = function: - nixpkgs.lib.genAttrs [ - "x86_64-linux" - "aarch64-darwin" - ] (system: - function rec { - pkgs = nixpkgs.legacyPackages.${system}; - inherit (pkgs.beam.interpreters) erlang_26; - inherit (pkgs.beam) packagesWith; - beam-pkgs = packagesWith erlang_26; - deps = import ./nix/deps.nix { - inherit (pkgs) lib; - beamPackages = beam-pkgs; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; + flake-parts.url = "github:hercules-ci/flake-parts"; + systems.url = "github:nix-systems/default"; + }; + + outputs = { + flake-parts, + systems, + ... + } @ inputs: + flake-parts.lib.mkFlake {inherit inputs;} { + systems = import systems; + perSystem = { + pkgs, + system, + ... + }: let + inherit (pkgs.beam.interpreters) erlangR26; + inherit (pkgs.beam) packagesWith; + beam = packagesWith erlangR26; + in { + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + config.allowUnfree = true; + }; + devShells.default = with pkgs; + mkShell { + name = "gotrue-ex"; + packages = with pkgs; + [beam.elixir_1_16] + ++ lib.optional stdenv.isLinux [inotify-tools] + ++ lib.optional stdenv.isDarwin [ + darwin.apple_sdk.frameworks.CoreServices + darwin.apple_sdk.frameworks.CoreFoundation + ]; }; - }); - in { - devShells = for-all-systems ({ - pkgs, - beam-pkgs, - ... - }: rec { - default = supabase-potion; - supabase-potion = pkgs.mkShell { - name = "supabase-potion"; - shellHook = "mkdir -p $PWD/.nix-mix"; - packages = with pkgs; - [beam-pkgs.elixir_1_15 earthly] - ++ lib.optional stdenv.isDarwin [ - darwin.apple_sdk.frameworks.CoreServices - darwin.apple_sdk.frameworks.CoreFoundation - ]; }; - }); - }; + }; }