zephyr-nix/python.nix

36 lines
939 B
Nix
Raw Normal View History

2024-02-06 02:52:10 +00:00
{ python3
, zephyr-src
, pyproject-nix
, clang-tools
, gitlint
, lib
2024-02-06 02:52:10 +00:00
}:
let
python = python3.override {
self = python;
packageOverrides = self: super: {
# HACK: Zephyr uses pypi to install non-Python deps
2024-02-06 02:52:10 +00:00
clang-format = clang-tools;
inherit gitlint;
# HACK: Older Zephyr depends on these missing dependencies
sphinxcontrib-svg2pdfconverter = super.sphinxcontrib-svg2pdfconverter or null;
2024-02-06 02:52:10 +00:00
};
};
project = pyproject-nix.lib.project.loadRequirementsTxt {
requirements = zephyr-src + "/scripts/requirements.txt";
};
invalidConstraints = project.validators.validateVersionConstraints { inherit python; };
2024-02-06 02:52:10 +00:00
in
lib.warnIf
(invalidConstraints != { })
"zephyr-pythonEnv: Found invalid Python constraints for: ${builtins.toJSON (lib.attrNames invalidConstraints)}"
(python.withPackages (project.renderers.withPackages {
inherit python;
extraPackages = ps: [ ps.west ];
}))