From 4bfbc45869b358a32cbd5b47c26326a08f9e34a7 Mon Sep 17 00:00:00 2001 From: Theodore Ni <3806110+tjni@users.noreply.github.com> Date: Thu, 13 Jul 2023 23:40:30 -0700 Subject: [PATCH] dbt: init at 1.5.3 Add a top-level dbt application with a passthru function that should be used to extend it with adapters. --- .../python-modules/dbt-core/default.nix | 22 +++++++++++++++++++ .../python-modules/dbt-core/with-adapters.nix | 18 +++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 3 files changed, 42 insertions(+) create mode 100644 pkgs/development/python-modules/dbt-core/with-adapters.nix diff --git a/pkgs/development/python-modules/dbt-core/default.nix b/pkgs/development/python-modules/dbt-core/default.nix index f522cb1d239..bd346c3262d 100644 --- a/pkgs/development/python-modules/dbt-core/default.nix +++ b/pkgs/development/python-modules/dbt-core/default.nix @@ -1,4 +1,5 @@ { lib +, python3 , buildPythonPackage , fetchFromGitHub , agate @@ -81,11 +82,32 @@ buildPythonPackage rec { # tests exist for the dbt tool but not for this package specifically doCheck = false; + passthru = { + withAdapters = python3.pkgs.callPackage ./with-adapters.nix { }; + }; + meta = with lib; { description = "Enables data analysts and engineers to transform their data using the same practices that software engineers use to build applications"; + longDescription = '' + The dbt tool needs adapters to data sources in order to work. The available + adapters are: + + dbt-bigquery + dbt-postgres + dbt-redshift + dbt-snowflake + + An example of building this package with a few adapters: + + dbt.withAdapters (adapters: [ + adapters.dbt-bigquery + adapters.dbt-postgres + ]) + ''; homepage = "https://github.com/dbt-labs/dbt-core"; changelog = "https://github.com/dbt-labs/dbt-core/blob/v${version}/CHANGELOG.md"; license = licenses.asl20; maintainers = with maintainers; [ mausch tjni ]; + mainProgram = "dbt"; }; } diff --git a/pkgs/development/python-modules/dbt-core/with-adapters.nix b/pkgs/development/python-modules/dbt-core/with-adapters.nix new file mode 100644 index 00000000000..006f4a96b85 --- /dev/null +++ b/pkgs/development/python-modules/dbt-core/with-adapters.nix @@ -0,0 +1,18 @@ +{ python3 +, dbt-bigquery +, dbt-core +, dbt-postgres +, dbt-redshift +, dbt-snowflake +}: +let + adapters = { + inherit dbt-bigquery dbt-postgres dbt-redshift dbt-snowflake; + }; +in +adapterFun: (python3.buildEnv.override { + extraLibs = [ dbt-core ] ++ (adapterFun adapters); + ignoreCollisions = true; +}).overrideAttrs { + meta.mainProgram = dbt-core.meta.mainProgram; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a84f1600cef..997e0415888 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -18752,6 +18752,8 @@ with pkgs; cwltool = callPackage ../applications/science/misc/cwltool { }; + dbt = with python3Packages; toPythonApplication dbt-core; + dprint = callPackage ../development/tools/dprint { inherit (darwin.apple_sdk.frameworks) Security; };