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