python3Packages.furo: Fix build on platforms without nodejs (#473963)

This commit is contained in:
Aleksana
2026-01-01 02:50:00 +00:00
committed by GitHub

View File

@@ -1,19 +1,38 @@
{
stdenv,
lib,
nodejs,
buildNpmPackage,
buildPythonPackage,
runCommand,
fetchFromGitHub,
fetchPypi,
flit-core,
accessible-pygments,
beautifulsoup4,
pygments,
sphinx,
sphinx-basic-ng,
unzip,
}:
let
pname = "furo";
version = "2025.07.19";
# version on pypi doesn't have month & day padded with 0
pypiVersion =
let
versionComponents = lib.strings.splitString "." version;
dropLeadingZero = lib.strings.removePrefix "0";
in
# year
(lib.lists.elemAt versionComponents 0)
+ "."
# month
+ (dropLeadingZero (lib.lists.elemAt versionComponents 1))
+ "."
# day
+ (dropLeadingZero (lib.lists.elemAt versionComponents 2));
src = fetchFromGitHub {
owner = "pradyunsg";
@@ -22,7 +41,28 @@ let
hash = "sha256-pIF5zrh5YbkuSkrateEB/tDULSNbeVn2Qx+Fm3nOYGE=";
};
web = buildNpmPackage {
web-bin =
let
web-bin-src = fetchPypi {
inherit pname;
version = pypiVersion;
format = "wheel";
dist = "py3";
python = "py3";
hash = "sha256-veqGmCLf0rSU6oTAlzk3410Vda8Ii2chopx/eHityeM=";
};
in
runCommand "${pname}-web-bin"
{
nativeBuildInputs = [ unzip ];
}
''
mkdir $out
unzip ${web-bin-src}
cp -rv furo/theme/furo/static/{scripts,styles} $out/
'';
web-native = buildNpmPackage {
pname = "${pname}-web";
inherit version src;
@@ -35,6 +75,8 @@ let
popd
'';
};
web = if (lib.meta.availableOn stdenv.buildPlatform nodejs) then web-native else web-bin;
in
buildPythonPackage rec {