nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 flit-core,
8
9 # dependencies
10 black,
11 click,
12 libcst,
13 moreorless,
14 tomlkit,
15 trailrunner,
16 typing-extensions,
17 usort,
18
19 # optional-dependencies
20 pygls,
21 ruff-api,
22
23 # tests
24 unittestCheckHook,
25 versionCheckHook,
26}:
27
28buildPythonPackage rec {
29 pname = "ufmt";
30 version = "2.9.0";
31 pyproject = true;
32
33 src = fetchFromGitHub {
34 owner = "omnilib";
35 repo = "ufmt";
36 tag = "v${version}";
37 hash = "sha256-/5sfawsBmsStCCdu4lIq2iL0zywrWAN+qW/t3h2UIu0=";
38 };
39
40 build-system = [ flit-core ];
41
42 dependencies = [
43 black
44 click
45 libcst
46 moreorless
47 tomlkit
48 trailrunner
49 typing-extensions
50 usort
51 ];
52
53 optional-dependencies = {
54 lsp = [ pygls ];
55 ruff = [ ruff-api ];
56 };
57
58 nativeCheckInputs = [
59 unittestCheckHook
60 versionCheckHook
61 ]
62 ++ lib.concatAttrValues optional-dependencies;
63
64 pythonImportsCheck = [ "ufmt" ];
65
66 meta = {
67 description = "Safe, atomic formatting with black and usort";
68 homepage = "https://github.com/omnilib/ufmt";
69 changelog = "https://github.com/omnilib/ufmt/blob/${version}/CHANGELOG.md";
70 license = lib.licenses.mit;
71 maintainers = with lib.maintainers; [ fab ];
72 mainProgram = "ufmt";
73 };
74}