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