Packaging supabase python library gone wrong

Hi all, I am trying to add the supabase python library to my dev shell, since it’s not yet been added to nixpkgs. So far I have this code, but it tells me that I am missing some of it’s dependencies like supafunc, gotrue, etc. I am kind of lost right now as to how to fix these issues.

flake.nix:

{
  description = "Computer Vision OCR Project Flake";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let 
        pkgs = import nixpkgs {
          inherit system;
          overlays = [
            (final: prev: {
              python = prev.python3; # Use Python 3
            })
          ];
        };

        pythonPackages = pkgs.python.pkgs;

        # Define a derivation for the supabase package from PyPI.
        supabase = pythonPackages.buildPythonPackage rec {
          pname = "supabase";
          version = "2.13.0";  # Replace with the desired version from PyPI
          src = pkgs.fetchPypi {
            inherit pname version;
            # Replace the sha256 with the one computed for that version.
            sha256 = "sha256-RSV000vZeMjRG18CsBgrSOiFTlEclpSDyDh17AFJXxE=";
          };
          format = "pyproject";
          usePep517 = true;
          nativeBuildInputs = [ pythonPackages.poetry-core ];

          pythonRuntimeDepsCheckHook = "";
          meta = with pkgs.lib; {
            description = "Supabase Python client library";
            license = licenses.mit;
          };
        };

        my-python-env = pkgs.python.withPackages (ps: with ps; [
          numpy
          opencv4
          pillow
          pytesseract
          scikit-learn
          pytest
          pytest-cov
          pandas
          python-dotenv
          supabase  # Add the custom supabase package here
        ]);

      in {
        devShells = {
          default = pkgs.mkShell {
            buildInputs = [
              my-python-env
              pkgs.tesseract
              pkgs.git
            ];

            shellHook = ''
              export PATH="$HOME/.local/bin:$PATH"
            '';
          };
        };

        packages = {
          default = my-python-env;
        };
      }
    );
}

All those packages need to be added to dependencies.

usePep517 is also doing nothing, you probably meant pyproject = true; which lets you drop format as well.

1 Like

dependencies as in Jupyterlab and an R env - #9 by philipwilk

There are two issues that I have with that.

  1. Three of the libraries (supafunc, realtime, and storage3) are also not on the nixpkgs repo yet, so how would I add them to dependencies?
  2. I tried doing it without those packages just to see what the error would be, but I get an error that “dependencies missing”.

flake.nix:

{
  description = "Computer Vision OCR Project Flake";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let 
        pkgs = import nixpkgs {
          inherit system;
          overlays = [
            (final: prev: {
              python = prev.python3; # Use Python 3
            })
          ];
        };

        pythonPackages = pkgs.python.pkgs;

        # Define a derivation for the supabase package from PyPI.
        supabase = pythonPackages.buildPythonPackage rec {
          pname = "supabase";  
          version = "2.13.0";  # Replace with the desired version from PyPI
          src = pkgs.fetchPypi {
            inherit pname version;
            # Replace the sha256 with the one computed for that version.
            sha256 = "sha256-RSV000vZeMjRG18CsBgrSOiFTlEclpSDyDh17AFJXxE=";
          };
          pyproject = true;

          meta = with pkgs.lib; {
            description = "Supabase Python client library";
            license = licenses.mit;
          };

        };

        my-python-env = pkgs.python3.withPackages (ps: with ps; [
          (supabase.overridePythonAttrs (previousAttrs: {
            dependencies = previousAttrs.dependencies ++ [ 
              pkgs.gotrue-supabase
              pkgs.httpx
              pkgs.postgrest
            ];
          }))
          numpy
          opencv4
          pillow
          pytesseract
          scikit-learn
          pytest
          pytest-cov
          pandas
          python-dotenv
            # Add the custom supabase package here
        ]);

      in {
        devShells = {
          default = pkgs.mkShell {
            buildInputs = [
              my-python-env
              pkgs.tesseract
              pkgs.git
            ];

            shellHook = ''
              export PATH="$HOME/.local/bin:$PATH"
            '';
          };
        };

        packages = {
          default = my-python-env;
        };
      }
    );
}

Maybe I’m doing something wrong here, but I still don’t see how to fix this issue.