summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/keymap-drawer/default.nix
blob: bece9396dd9f7f34970b8b74ddd076acd22bf59a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
{
  lib,

  buildPythonPackage,
  callPackages,
  fetchFromGitHub,
  pythonOlder,

  keymap-drawer,
  nix-update-script,
  pcpp,
  platformdirs,
  poetry-core,
  pydantic,
  pydantic-settings,
  pyparsing,
  pyyaml,
  tree-sitter,
  tree-sitter-grammars,
  versionCheckHook,
}:
let
  version = "0.22.1";
in
buildPythonPackage {
  inherit version;
  pname = "keymap-drawer";
  pyproject = true;
  disabled = pythonOlder "3.12";

  src = fetchFromGitHub {
    owner = "caksoylar";
    repo = "keymap-drawer";
    tag = "v${version}";
    hash = "sha256-X3O5yspEdey03YQ6JsYN/DE9NUiq148u1W6LQpUQ3ns=";
  };

  build-system = [ poetry-core ];

  pythonRelaxDeps = [
    "tree-sitter-devicetree"
  ];

  dependencies = [
    pcpp
    platformdirs
    pydantic
    pydantic-settings
    pyparsing
    pyyaml
    tree-sitter
    tree-sitter-grammars.tree-sitter-devicetree
  ];

  nativeCheckInputs = [
    versionCheckHook
  ];

  pythonImportsCheck = [ "keymap_drawer" ];

  versionCheckProgram = "${placeholder "out"}/bin/keymap";

  passthru.tests = callPackages ./tests {
    # Explicitly pass the correctly scoped package.
    # The top-level package will still resolve to itself, because the way
    # `toPythonApplication` interacts with scopes is weird.
    inherit keymap-drawer;
  };
  passthru.updateScript = nix-update-script { };

  meta = {
    description = "Module and CLI tool to help parse and draw keyboard layouts";
    homepage = "https://github.com/caksoylar/keymap-drawer";
    changelog = "https://github.com/caksoylar/keymap-drawer/releases/tag/v${version}";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [
      MattSturgeon
    ];
    mainProgram = "keymap";
    # keymap-drawer currently requires tree-sitter 0.24.0
    # See https://github.com/caksoylar/keymap-drawer/issues/183
    # top-level package `keymap-drawer` is not broken due to this
    # incompatibility, thanks to a Python override
    broken = lib.versionAtLeast tree-sitter.version "0.25.0";
  };
}