1{
2 lib,
3 black,
4 buildPythonPackage,
5 click,
6 fetchFromGitHub,
7 fetchPypi,
8 gitpython,
9 importlib-metadata,
10 jinja2,
11 platformdirs,
12 poetry-core,
13 pytest-asyncio,
14 pytestCheckHook,
15 pythonOlder,
16 tomli,
17 tqdm,
18}:
19
20buildPythonPackage rec {
21 pname = "sqlfmt";
22 version = "0.23.3";
23 pyproject = true;
24
25 disabled = pythonOlder "3.9";
26
27 src = fetchFromGitHub {
28 owner = "tconbeer";
29 repo = "sqlfmt";
30 rev = "refs/tags/v${version}";
31 hash = "sha256-kbluj29P1HwTaCYv1Myslak9s8FFm2e/eHdGgi3H4i0=";
32 };
33
34 pythonRelaxDeps = [ "platformdirs" ];
35
36 build-system = [ poetry-core ];
37
38 dependencies = [
39 click
40 importlib-metadata
41 jinja2
42 platformdirs
43 tomli
44 tqdm
45 ];
46
47 optional-dependencies = {
48 jinjafmt = [ black ];
49 sqlfmt_primer = [ gitpython ];
50 };
51
52 nativeCheckInputs = [
53 pytest-asyncio
54 pytestCheckHook
55 ] ++ lib.flatten (builtins.attrValues optional-dependencies);
56
57 preCheck = ''
58 export HOME=$(mktemp -d)
59 export PATH="$PATH:$out/bin";
60 '';
61
62 pythonImportsCheck = [ "sqlfmt" ];
63
64 meta = {
65 description = "Sqlfmt formats your dbt SQL files so you don't have to";
66 homepage = "https://github.com/tconbeer/sqlfmt";
67 changelog = "https://github.com/tconbeer/sqlfmt/blob/${src.rev}/CHANGELOG.md";
68 license = lib.licenses.asl20;
69 maintainers = with lib.maintainers; [ pcboy ];
70 mainProgram = "sqlfmt";
71 };
72}