2023-01-25 18:19:35 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, python3
|
|
|
|
, python3Minimal
|
2023-02-05 06:48:49 +00:00
|
|
|
, runCommand
|
2023-01-25 18:19:35 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
# python3Minimal can't be overridden with packages on Darwin, due to a missing framework.
|
|
|
|
# Instead of modifying stdenv, we take the easy way out, since most people on Darwin will
|
|
|
|
# just be hacking on the Nixpkgs manual (which also uses make-options-doc).
|
|
|
|
python = ((if stdenv.isDarwin then python3 else python3Minimal).override {
|
|
|
|
self = python;
|
|
|
|
includeSiteCustomize = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
# TODO add our own small test suite, maybe add tests for these deps to channels?
|
|
|
|
markdown-it-py-no-tests = python.pkgs.markdown-it-py.override {
|
|
|
|
disableTests = true;
|
|
|
|
};
|
|
|
|
mdit-py-plugins-no-tests = python.pkgs.mdit-py-plugins.override {
|
|
|
|
markdown-it-py = markdown-it-py-no-tests;
|
|
|
|
disableTests = true;
|
|
|
|
};
|
2023-02-05 06:48:49 +00:00
|
|
|
|
|
|
|
makeDeps = pkgs: small:
|
2023-02-19 19:51:39 +00:00
|
|
|
if small
|
|
|
|
then [
|
|
|
|
markdown-it-py-no-tests
|
|
|
|
mdit-py-plugins-no-tests
|
|
|
|
]
|
|
|
|
else [
|
|
|
|
pkgs.markdown-it-py
|
|
|
|
pkgs.mdit-py-plugins
|
|
|
|
];
|
2023-01-25 18:19:35 +00:00
|
|
|
in
|
|
|
|
|
2023-02-05 06:48:49 +00:00
|
|
|
python.pkgs.buildPythonApplication rec {
|
2023-01-25 18:19:35 +00:00
|
|
|
pname = "nixos-render-docs";
|
|
|
|
version = "0.0";
|
|
|
|
format = "pyproject";
|
|
|
|
|
|
|
|
src = lib.cleanSourceWith {
|
|
|
|
filter = name: type:
|
|
|
|
lib.cleanSourceFilter name type
|
|
|
|
&& ! (type == "directory"
|
|
|
|
&& builtins.elem
|
|
|
|
(baseNameOf name)
|
|
|
|
[
|
|
|
|
".pytest_cache"
|
|
|
|
".mypy_cache"
|
|
|
|
"__pycache__"
|
|
|
|
]);
|
|
|
|
src = ./src;
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
python.pkgs.setuptools
|
2023-01-25 00:08:49 +00:00
|
|
|
python.pkgs.pytestCheckHook
|
2023-01-25 18:19:35 +00:00
|
|
|
];
|
|
|
|
|
2023-02-05 06:48:49 +00:00
|
|
|
propagatedBuildInputs = makeDeps python.pkgs true;
|
2023-01-25 18:19:35 +00:00
|
|
|
|
2023-01-25 00:08:49 +00:00
|
|
|
pytestFlagsArray = [ "-vvrP" "tests/" ];
|
|
|
|
|
2023-02-05 06:48:49 +00:00
|
|
|
# NOTE this is a CI test rather than a build-time test because we want to keep the
|
|
|
|
# build closures small. mypy has an unreasonably large build closure for docs builds.
|
|
|
|
passthru.tests.typing = runCommand "${pname}-mypy" {
|
|
|
|
nativeBuildInputs = [
|
|
|
|
(python3.withPackages (p: [ p.mypy p.pytest ] ++ makeDeps p false))
|
|
|
|
];
|
|
|
|
} ''
|
|
|
|
mypy --strict ${src}
|
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
|
2023-01-25 18:19:35 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Renderer for NixOS manual and option docs";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = [ ];
|
|
|
|
};
|
|
|
|
}
|