diff --git a/flake.nix b/flake.nix index 2e6e3d8..c121e3d 100644 --- a/flake.nix +++ b/flake.nix @@ -11,21 +11,30 @@ outputs = {self, nixpkgs, rust-overlay, flake-utils, ...}: flake-utils.lib.eachDefaultSystem(system: let - dbt-overlay = import ./nix/dbt-core/overlay.nix; + dbt-overlay = import ./nix/overlay.nix; # TODO(jwall): Is this overlay strictly necessary? pkgs = import nixpkgs {inherit system; overlays = [ dbt-overlay rust-overlay.overlay ]; }; dbt-core = import ./nix/dbt-core/default.nix { inherit pkgs; }; + dbt-postgres = import ./nix/dbt-postgres/default.nix { inherit pkgs dbt-core; }; + dbt-redshift = import ./nix/dbt-redshift/default.nix { inherit pkgs dbt-core dbt-postgres; }; in { + dbt-core = dbt-core; + dbt-redshift = dbt-redshift; + overlays = [ dbt-overlay rust-overlay ]; defaultPackage = dbt-core; - packages.dbt-core = dbt-core; + packages = { + dbt-core = dbt-core; + dbt-redshift = dbt-redshift; + }; defaultApp = { type = "app"; program = "${dbt-core}/bin/dbt"; }; + # Okay now nix develop should work. devShell = pkgs.mkShell { - buildInputs = [ dbt-core ]; + packages = [ dbt-core dbt-redshift dbt-postgres pkgs.python39 pkgs.python39Packages.pip ]; }; }); } \ No newline at end of file diff --git a/nix/dbt-core/default.nix b/nix/dbt-core/default.nix index 751ba19..5fd73dc 100644 --- a/nix/dbt-core/default.nix +++ b/nix/dbt-core/default.nix @@ -2,47 +2,6 @@ with pkgs; with python39Packages; let inputs = [ - #attrs - #Babel - #boto3 - #agate - #certifi - #cffi - #click - #colorama - #hologram - #idna - #importlib-metadata - #isodate - #jinja2 - #leather - #Logbook - #markupsafe - #msgpack - #networkx - #packaging - #parsedatetime - #psycopg2 - #pycparser - #pyparsing - #pyrsistent - #python-dateutil - #python-slugify - #pytimeparse - #pytz - #requests - #sqlparse - #text-unidecode - #typing-extensions - #urllib3 - #werkzeug - #zipp - #pyopenssl - #vcversioner - #six - #snowflake-connector-python - #charset-normalizer - #dbt-postgres jsonschema networkx mashumaro diff --git a/nix/dbt-postgres/default.nix b/nix/dbt-postgres/default.nix new file mode 100644 index 0000000..8066598 --- /dev/null +++ b/nix/dbt-postgres/default.nix @@ -0,0 +1,27 @@ + +{pkgs, dbt-core}: +with pkgs; +with python39Packages; +let inputs = [ + dbt-core + typing-extensions + jinja2 + psycopg2 +]; +in +buildPythonPackage rec { + pname = "dbt-postgres"; + version = "1.0.0"; + buildInputs = inputs; + propagatedBuildInputs = inputs; + doCheck = false; + # This is gross but I couldn't figure out how to set an environment variable + # to configure this properly. + patchPhase = '' + sed -ibak "s/return 'psycopg2-binary'/return 'psycopg2'/" setup.py + ''; + src = fetchPypi { + inherit pname version; + sha256 = "sha256-eOrEulixIEBx3oTbaaxE3Gg3K2gNo5h5QoJhM48SKZI="; + }; +} \ No newline at end of file diff --git a/nix/dbt-redshift/default.nix b/nix/dbt-redshift/default.nix new file mode 100644 index 0000000..572d8da --- /dev/null +++ b/nix/dbt-redshift/default.nix @@ -0,0 +1,23 @@ +{pkgs, dbt-core, dbt-postgres}: +with pkgs; +with python39Packages; +let inputs = [ + dbt-core + boto3 + typing-extensions + jinja2 + dbt-postgres + #jinja2_3 +]; +in +buildPythonPackage rec { + pname = "dbt-redshift"; + version = "1.0.0"; + buildInputs = inputs; + propagatedBuildInputs = inputs; + doCheck = false; + src = fetchPypi { + inherit pname version; + sha256 = "sha256-ZBkhKxxUA1jyubMkCPzmvqyTh8QPgQ2Y33gEOV6Sc78="; + }; +} \ No newline at end of file diff --git a/nix/dbt-core/overlay.nix b/nix/overlay.nix similarity index 90% rename from nix/dbt-core/overlay.nix rename to nix/overlay.nix index 982a35b..173c1bb 100644 --- a/nix/dbt-core/overlay.nix +++ b/nix/overlay.nix @@ -8,8 +8,8 @@ nativeBuildInputs = with self.rustPlatform; [ cargoSetupHook maturinBuildHook ]; - # some platforms (MacOS) require this - buildInputs = [ self.libiconv ]; + # some platforms (MacOS) require this + buildInputs = [ self.libiconv ]; src = pyself.fetchPypi { inherit pname version; sha256 = "sha256-WGcuNvq5iMhJppNAWSDuGEIfJyRcSOX57PSWNp7TGoU="; @@ -118,6 +118,22 @@ sha256 = "sha256-ptWEM94K6AA0fKsfowQ867q+i6qdKeZo8cdoy4ejM8Y="; }; }); + psycopg2 = pysuper.psycopg2.overrideAttrs (oldAttrs: rec { + pname = "psycopg2"; + version = "2.8"; + src = pyself.fetchPypi { + inherit pname version; + sha256 = "sha256-ScWDjZDoMheQnbN4nTChBThbXmluxRaM2mRVRsVC81o="; + }; + }); + #jinja2_3 = pysuper.jinja2.overrideAttrs (oldAttrs: rec { + # version = "3.0.0"; + # pname = oldAttrs.pname; + # src = pyself.fetchPypi { + # inherit pname version; + # sha256 = "sha256-6o192BTOnfbeanYex/HKyYr+MFuM3Eqq5OEUuNjOJMU="; + # }; + #}); logbook = with pyself; buildPythonPackage rec { pname = "Logbook"; version = "1.5.3"; @@ -130,10 +146,10 @@ }; typing-extensions = with pyself; buildPythonPackage rec { pname = "typing_extensions"; - version = "3.7.4.3"; + version = "3.10.0.2"; src = fetchPypi { inherit pname version; - sha256 = "sha256-mdQHO2F9MCiPVp0/E9K9dUjDp+TI3ofbCanSm7Okpgw="; + sha256 = "sha256-SfddFv8R8c0ljhuYjM/4KjylVwIX162MX0ggXdmaZ34="; }; }; python-dateutil = pysuper.python-dateutil.overrideAttrs (oldAttrs: rec { @@ -173,23 +189,6 @@ # license = licenses.isc; # }; #}; - #vcversioner = pyself.buildPythonPackage rec { - # version = "2.16.0.0"; - # pname = "vcversioner"; - # src = pyself.fetchPypi { - # inherit pname version; - # sha256 = "sha256-2uYMF6R5eB9EpAEHAYM/GCkUCx7szSWHYqdJdKoG4Zs="; - # }; - #}; - #snowflake-connector-python = pysuper.snowflake-connector-python.overrideAttrs (oldAttrs: rec { - # version = "2.4.1"; - # pname = oldAttrs.pname; - # src = pyself.fetchPypi { - # inherit pname; - # inherit version; - # sha256 = "1bms4z3zjxzzg0m9smgf0h5cm49h8a41c8w3vyqvx9q22bk814aw"; - # }; - #}); }); }; }) diff --git a/shell.nix b/shell.nix deleted file mode 100644 index dac9a84..0000000 --- a/shell.nix +++ /dev/null @@ -1,24 +0,0 @@ -with import {}; - -stdenv.mkDerivation { - name = "pip-env"; - buildInputs = [ - # System requirements. - readline - git - - # Python requirements (enough to get a virtualenv going). - python39Full - python39Packages.virtualenv - python39Packages.pip - python39Packages.setuptools - ]; - src = null; - shellHook = '' - # Allow the use of wheels. - SOURCE_DATE_EPOCH=$(date +%s) - - # Augment the dynamic linker path - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${R}/lib/R/lib:${readline}/lib - ''; -} \ No newline at end of file