From 43c19133f4d71287c831b3a4f8f661de081d3fb3 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Thu, 25 Dec 2025 00:12:42 +0100 Subject: [PATCH] python3Packages.furo: Fix build on platforms without nodejs When nodejs is unavailable, fetch the JS & CSS files from upstream's wheel. --- .../python-modules/furo/default.nix | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/furo/default.nix b/pkgs/development/python-modules/furo/default.nix index aaccb336fa97..f676a9b0b979 100644 --- a/pkgs/development/python-modules/furo/default.nix +++ b/pkgs/development/python-modules/furo/default.nix @@ -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 {