nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pythonOlder,
6
7 # build-system
8 hatchling,
9
10 # dependencies
11 click,
12 jinja2,
13 platformdirs,
14 tqdm,
15
16 # optional-dependencies
17 black,
18 gitpython,
19
20 # tests
21 addBinToPathHook,
22 pytest-asyncio,
23 pytestCheckHook,
24 versionCheckHook,
25 writableTmpDirAsHomeHook,
26}:
27
28buildPythonPackage rec {
29 pname = "sqlfmt";
30 version = "0.29.0";
31 pyproject = true;
32
33 disabled = pythonOlder "3.12";
34
35 src = fetchFromGitHub {
36 owner = "tconbeer";
37 repo = "sqlfmt";
38 tag = "v${version}";
39 hash = "sha256-AeG6ga+WaBVvCCkEJbIkaJQg4rEmBcyQNmgJHEYkhrI=";
40 };
41
42 build-system = [ hatchling ];
43
44 pythonRelaxDeps = [
45 "click"
46 ];
47 dependencies = [
48 click
49 jinja2
50 platformdirs
51 tqdm
52 ];
53
54 optional-dependencies = {
55 jinjafmt = [ black ];
56 sqlfmt_primer = [ gitpython ];
57 };
58
59 pythonImportsCheck = [ "sqlfmt" ];
60
61 nativeCheckInputs = [
62 addBinToPathHook
63 pytest-asyncio
64 pytestCheckHook
65 versionCheckHook
66 writableTmpDirAsHomeHook
67 ]
68 ++ lib.concatAttrValues optional-dependencies;
69
70 disabledTestPaths = [
71 # TypeError: CliRunner.__init__() got an unexpected keyword argument 'mix_stderr'
72 "tests/functional_tests/test_end_to_end.py"
73 "tests/unit_tests/test_cli.py"
74 ];
75
76 meta = {
77 description = "Sqlfmt formats your dbt SQL files so you don't have to";
78 homepage = "https://github.com/tconbeer/sqlfmt";
79 changelog = "https://github.com/tconbeer/sqlfmt/blob/${src.tag}/CHANGELOG.md";
80 license = lib.licenses.asl20;
81 maintainers = with lib.maintainers; [ pcboy ];
82 mainProgram = "sqlfmt";
83 };
84}