1{ stdenv
2, lib
3, buildPythonPackage
4, fetchFromGitHub
5, jsonschema
6, pythonOlder
7, rfc3987
8, ruamel-yaml
9, setuptools-scm
10, libfdt
11}:
12
13buildPythonPackage rec {
14 pname = "dtschema";
15 version = "2023.04";
16 format = "setuptools";
17
18 disabled = pythonOlder "3.7";
19
20 src = fetchFromGitHub {
21 owner = "devicetree-org";
22 repo = "dt-schema";
23 rev = "refs/tags/v${version}";
24 sha256 = "sha256-w9TsRdiDTdExft7rdb2hYcvxP6hxOFZKI3hITiNSwgw=";
25 };
26
27 patches = [
28 # Change name of pylibfdt to libfdt
29 ./fix_libfdt_name.patch
30 ];
31
32 SETUPTOOLS_SCM_PRETEND_VERSION = version;
33
34 nativeBuildInputs = [
35 setuptools-scm
36 ];
37
38 propagatedBuildInputs = [
39 jsonschema
40 rfc3987
41 ruamel-yaml
42 libfdt
43 ];
44
45 # Module has no tests
46 doCheck = false;
47
48 pythonImportsCheck = [
49 "dtschema"
50 ];
51
52 meta = with lib; {
53 description = "Tooling for devicetree validation using YAML and jsonschema";
54 homepage = "https://github.com/devicetree-org/dt-schema/";
55 changelog = "https://github.com/devicetree-org/dt-schema/releases/tag/v${version}";
56 license = with licenses; [ bsd2 /* or */ gpl2Only ];
57 maintainers = with maintainers; [ sorki ];
58
59 broken = (
60 # Library not loaded: @rpath/libfdt.1.dylib
61 stdenv.isDarwin ||
62
63 # see https://github.com/devicetree-org/dt-schema/issues/108
64 versionAtLeast jsonschema.version "4.18"
65 );
66 };
67}
68