1{
2 lib,
3 python3,
4 runCommand,
5}:
6
7let
8 python = python3.override {
9 self = python;
10 packageOverrides = final: prev: {
11 markdown-it-py = prev.markdown-it-py.overridePythonAttrs (_: {
12 doCheck = false;
13 });
14 mdit-py-plugins = prev.mdit-py-plugins.overridePythonAttrs (_: {
15 doCheck = false;
16 });
17 };
18 };
19in
20
21python.pkgs.buildPythonApplication rec {
22 pname = "nixos-render-docs";
23 version = "0.0";
24 format = "pyproject";
25
26 src = lib.cleanSourceWith {
27 filter =
28 name: type:
29 lib.cleanSourceFilter name type
30 && !(
31 type == "directory"
32 && builtins.elem (baseNameOf name) [
33 ".pytest_cache"
34 ".mypy_cache"
35 "__pycache__"
36 ]
37 );
38 src = ./src;
39 };
40
41 nativeCheckInputs = [
42 python.pkgs.pytestCheckHook
43 ];
44
45 build-system = [
46 python.pkgs.setuptools
47 ];
48
49 propagatedBuildInputs = with python.pkgs; [
50 markdown-it-py
51 mdit-py-plugins
52 ];
53
54 pytestFlags = [
55 "-vvrP"
56 ];
57
58 enabledTestPaths = [
59 "tests/"
60 ];
61
62 # NOTE this is a CI test rather than a build-time test because we want to keep the
63 # build closures small. mypy has an unreasonably large build closure for docs builds.
64 passthru.tests.typing =
65 runCommand "${pname}-mypy"
66 {
67 nativeBuildInputs = [
68 (python3.withPackages (
69 ps: with ps; [
70 mypy
71 pytest
72 markdown-it-py
73 mdit-py-plugins
74 ]
75 ))
76 ];
77 }
78 ''
79 mypy --strict ${src}
80 touch $out
81 '';
82
83 meta = with lib; {
84 description = "Renderer for NixOS manual and option docs";
85 mainProgram = "nixos-render-docs";
86 license = licenses.mit;
87 maintainers = [ ];
88 };
89}