at 23.11-beta 2.0 kB view raw
1{ lib 2, stdenv 3, python3 4, python3Minimal 5, runCommand 6}: 7 8let 9 # python3Minimal can't be overridden with packages on Darwin, due to a missing framework. 10 # Instead of modifying stdenv, we take the easy way out, since most people on Darwin will 11 # just be hacking on the Nixpkgs manual (which also uses make-options-doc). 12 python = ((if stdenv.isDarwin then python3 else python3Minimal).override { 13 self = python; 14 includeSiteCustomize = true; 15 }).override { 16 packageOverrides = final: prev: { 17 markdown-it-py = prev.markdown-it-py.overridePythonAttrs (_: { 18 doCheck = false; 19 }); 20 mdit-py-plugins = prev.mdit-py-plugins.overridePythonAttrs (_: { 21 doCheck = false; 22 }); 23 }; 24 }; 25in 26 27python.pkgs.buildPythonApplication rec { 28 pname = "nixos-render-docs"; 29 version = "0.0"; 30 format = "pyproject"; 31 32 src = lib.cleanSourceWith { 33 filter = name: type: 34 lib.cleanSourceFilter name type 35 && ! (type == "directory" 36 && builtins.elem 37 (baseNameOf name) 38 [ 39 ".pytest_cache" 40 ".mypy_cache" 41 "__pycache__" 42 ]); 43 src = ./src; 44 }; 45 46 nativeBuildInputs = with python.pkgs; [ 47 setuptools 48 pytestCheckHook 49 ]; 50 51 propagatedBuildInputs = with python.pkgs; [ 52 markdown-it-py 53 mdit-py-plugins 54 ]; 55 56 pytestFlagsArray = [ "-vvrP" "tests/" ]; 57 58 # NOTE this is a CI test rather than a build-time test because we want to keep the 59 # build closures small. mypy has an unreasonably large build closure for docs builds. 60 passthru.tests.typing = runCommand "${pname}-mypy" { 61 nativeBuildInputs = [ 62 (python3.withPackages (ps: with ps; [ mypy pytest markdown-it-py mdit-py-plugins ])) 63 ]; 64 } '' 65 mypy --strict ${src} 66 touch $out 67 ''; 68 69 meta = with lib; { 70 description = "Renderer for NixOS manual and option docs"; 71 license = licenses.mit; 72 maintainers = [ ]; 73 }; 74}