nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 122 lines 2.7 kB view raw
1{ 2 stdenv, 3 lib, 4 nodejs, 5 buildNpmPackage, 6 buildPythonPackage, 7 runCommand, 8 fetchFromGitHub, 9 fetchPypi, 10 flit-core, 11 accessible-pygments, 12 beautifulsoup4, 13 pygments, 14 sphinx, 15 sphinx-basic-ng, 16 unzip, 17}: 18 19let 20 pname = "furo"; 21 version = "2025.07.19"; 22 # version on pypi doesn't have month & day padded with 0 23 pypiVersion = 24 let 25 versionComponents = lib.strings.splitString "." version; 26 dropLeadingZero = lib.strings.removePrefix "0"; 27 in 28 # year 29 (lib.lists.elemAt versionComponents 0) 30 + "." 31 # month 32 + (dropLeadingZero (lib.lists.elemAt versionComponents 1)) 33 + "." 34 # day 35 + (dropLeadingZero (lib.lists.elemAt versionComponents 2)); 36 37 src = fetchFromGitHub { 38 owner = "pradyunsg"; 39 repo = "furo"; 40 tag = version; 41 hash = "sha256-pIF5zrh5YbkuSkrateEB/tDULSNbeVn2Qx+Fm3nOYGE="; 42 }; 43 44 web-bin = 45 let 46 web-bin-src = fetchPypi { 47 inherit pname; 48 version = pypiVersion; 49 format = "wheel"; 50 dist = "py3"; 51 python = "py3"; 52 hash = "sha256-veqGmCLf0rSU6oTAlzk3410Vda8Ii2chopx/eHityeM="; 53 }; 54 in 55 runCommand "${pname}-web-bin" 56 { 57 nativeBuildInputs = [ unzip ]; 58 } 59 '' 60 mkdir $out 61 unzip ${web-bin-src} 62 cp -rv furo/theme/furo/static/{scripts,styles} $out/ 63 ''; 64 65 web-native = buildNpmPackage { 66 pname = "${pname}-web"; 67 inherit version src; 68 69 npmDepsHash = "sha256-dcdHoyqF9zC/eKtEqMho7TK2E1KIvoXo0iwSPTzj+Kw="; 70 71 installPhase = '' 72 pushd src/furo/theme/furo/static 73 mkdir $out 74 cp -rv scripts styles $out/ 75 popd 76 ''; 77 }; 78 79 web = if (lib.meta.availableOn stdenv.buildPlatform nodejs) then web-native else web-bin; 80in 81 82buildPythonPackage rec { 83 inherit pname version src; 84 pyproject = true; 85 86 postPatch = '' 87 # build with boring backend that does not manage a node env 88 substituteInPlace pyproject.toml \ 89 --replace-fail "sphinx-theme-builder >= 0.2.0a10" "flit-core" \ 90 --replace-fail "sphinx_theme_builder" "flit_core.buildapi" 91 92 pushd src/furo/theme/furo/static 93 cp -rv ${web}/{scripts,styles} . 94 popd 95 ''; 96 97 build-system = [ flit-core ]; 98 99 pythonRelaxDeps = [ "sphinx" ]; 100 101 dependencies = [ 102 accessible-pygments 103 beautifulsoup4 104 pygments 105 sphinx 106 sphinx-basic-ng 107 ]; 108 109 pythonImportsCheck = [ "furo" ]; 110 111 passthru = { 112 inherit web; 113 }; 114 115 meta = { 116 description = "Clean customizable documentation theme for Sphinx"; 117 homepage = "https://github.com/pradyunsg/furo"; 118 changelog = "https://github.com/pradyunsg/furo/blob/${version}/docs/changelog.md"; 119 license = lib.licenses.mit; 120 maintainers = with lib.maintainers; [ Luflosi ]; 121 }; 122}