From 99cda4d5c7e6f7b427dea344b91f3207e5e6e11d Mon Sep 17 00:00:00 2001 From: TomaSajt <62384384+TomaSajt@users.noreply.github.com> Date: Thu, 24 Jul 2025 19:58:56 +0200 Subject: [PATCH 1/2] hotdoc: use callPackage, refactor clang usage --- pkgs/development/tools/hotdoc/clang.patch | 96 ++++++++++++++--------- pkgs/development/tools/hotdoc/default.nix | 58 +++----------- pkgs/top-level/all-packages.nix | 2 +- 3 files changed, 74 insertions(+), 82 deletions(-) diff --git a/pkgs/development/tools/hotdoc/clang.patch b/pkgs/development/tools/hotdoc/clang.patch index 53334206b7d5..cf5c10fca3d4 100644 --- a/pkgs/development/tools/hotdoc/clang.patch +++ b/pkgs/development/tools/hotdoc/clang.patch @@ -1,8 +1,32 @@ diff --git a/hotdoc/extensions/c/c_extension.py b/hotdoc/extensions/c/c_extension.py -index 1cfd5b3..cff20c8 100644 +index 1cfd5b3..1e1926f 100644 --- a/hotdoc/extensions/c/c_extension.py +++ b/hotdoc/extensions/c/c_extension.py -@@ -89,7 +89,7 @@ def get_clang_headers(): +@@ -44,14 +44,6 @@ from hotdoc.utils.loggable import (info as core_info, warn, Logger, + debug as core_debug) + + +-LLVM_CONFIG = os.environ.get("LLVM_CONFIG") +-if LLVM_CONFIG is None: +- LLVM_CONFIG = shutil.which('llvm-config') +- +-if LLVM_CONFIG is None: +- raise ImportError() +- +- + def ast_node_is_function_pointer(ast_node): + if ast_node.kind == cindex.TypeKind.POINTER and \ + ast_node.get_pointee().get_result().kind != \ +@@ -80,42 +72,26 @@ Logger.register_warning_code('clang-headers-not-found', HotdocException, + 'c-extension') + + +-CLANG_HEADERS_WARNING = ( +- 'Did not find clang headers. Please report a bug with the output of the' +- '\'llvm-config --version\' and \'llvm-config --prefix\' commands') +- +- + def get_clang_headers(): try: # Clang 5.0+ can tell us directly resource_dir = subprocess.check_output( @@ -11,42 +35,44 @@ index 1cfd5b3..cff20c8 100644 if len(resource_dir) > 0: include_dir = os.path.join(resource_dir, 'include') if os.path.exists(include_dir): + return include_dir + except subprocess.CalledProcessError: + pass +- version = subprocess.check_output( +- [LLVM_CONFIG, '--version']).strip().decode() +- prefix = subprocess.check_output( +- [LLVM_CONFIG, '--prefix']).strip().decode() +- versions = (version, version.split('.').pop(0)) +- for (ver, lib) in itertools.product( +- versions, +- ['lib', 'lib64']): +- p = os.path.join(prefix, lib, 'clang', ver, 'include') +- if os.path.exists(p): +- return p + +- warn('clang-headers-not-found', CLANG_HEADERS_WARNING) ++ warn('clang-headers-not-found', 'Did not find clang headers. Make sure you\'re using Clang 5.0+') + + + CLANG_HEADERS = get_clang_headers() + + + def get_clang_libdir(): +- return subprocess.check_output([LLVM_CONFIG, '--libdir']).strip().decode() ++ return '@libclang_lib_dir@' + + + class ClangScanner(object): diff --git a/hotdoc/extensions/c/clang/cindex.py b/hotdoc/extensions/c/clang/cindex.py -index fc93fda..2eb8eaf 100644 +index fc93fda..0a16651 100644 --- a/hotdoc/extensions/c/clang/cindex.py +++ b/hotdoc/extensions/c/clang/cindex.py -@@ -3937,20 +3937,23 @@ class Config: - if Config.library_file: - return Config.library_file +@@ -3949,6 +3949,8 @@ class Config: -- import platform -- name = platform.system() -+ if Config.library_path: -+ import platform -+ name = platform.system() + if Config.library_path: + file = Config.library_path + '/' + file ++ else: ++ file = "@libclang_lib_dir@" + '/' + file -- if name == 'Darwin': -- file = 'libclang.dylib' -- elif name == 'Windows': -- file = 'libclang.dll' -- else: -- file = 'libclang.so' -+ if name == 'Darwin': -+ file = 'libclang.dylib' -+ elif name == 'Windows': -+ file = 'libclang.dll' -+ else: -+ file = 'libclang.so' + return file -- if Config.library_path: -- file = Config.library_path + '/' + file -+ if Config.library_path: -+ file = Config.library_path + '/' + file -+ -+ return file - -- return file -+ return "@libclang@" - - def get_cindex_library(self): - try: diff --git a/pkgs/development/tools/hotdoc/default.nix b/pkgs/development/tools/hotdoc/default.nix index 64f7538ca37b..47862db4d978 100644 --- a/pkgs/development/tools/hotdoc/default.nix +++ b/pkgs/development/tools/hotdoc/default.nix @@ -1,37 +1,21 @@ { lib, stdenv, - buildPythonApplication, + python3Packages, fetchpatch, fetchPypi, replaceVars, - clang, - libclang, - pytestCheckHook, pkg-config, cmake, flex, glib, json-glib, libxml2, - appdirs, - backports-entry-points-selectable, - dbus-deviation, - faust-cchardet, - feedgen, - lxml, - networkx, - pkgconfig, - pyyaml, - schema, - setuptools, - toposort, - wheezy-template, llvmPackages, gst_all_1, }: -buildPythonApplication rec { +python3Packages.buildPythonApplication rec { pname = "hotdoc"; version = "0.17.4"; pyproject = true; @@ -43,8 +27,8 @@ buildPythonApplication rec { patches = [ (replaceVars ./clang.patch { - clang = lib.getExe clang; - libclang = "${lib.getLib libclang}/lib/libclang${stdenv.hostPlatform.extensions.sharedLibrary}"; + clang = lib.getExe llvmPackages.clang; + libclang_lib_dir = "${lib.getLib llvmPackages.libclang}/lib"; }) # Fix build with gcc15 @@ -55,7 +39,9 @@ buildPythonApplication rec { }) ]; - build-system = [ setuptools ]; + postPatch = '' + patch -p1 -d cmark -i ${./fix-cmake-4.patch} + ''; nativeBuildInputs = [ pkg-config @@ -66,10 +52,12 @@ buildPythonApplication rec { buildInputs = [ glib json-glib - libxml2.dev + libxml2 ]; - dependencies = [ + build-system = with python3Packages; [ setuptools ]; + + dependencies = with python3Packages; [ appdirs backports-entry-points-selectable dbus-deviation @@ -85,7 +73,7 @@ buildPythonApplication rec { wheezy-template ]; - nativeCheckInputs = [ pytestCheckHook ]; + nativeCheckInputs = with python3Packages; [ pytestCheckHook ]; # CMake is used to build CMARK, but the build system is still python dontUseCmakeConfigure = true; @@ -103,14 +91,6 @@ buildPythonApplication rec { "hotdoc" ]; - disabledTestPaths = [ - # Executing hotdoc exits with code 1 - "tests/test_hotdoc.py::TestHotdoc::test_basic" - "tests/test_hotdoc.py::TestHotdoc::test_explicit_conf_file" - "tests/test_hotdoc.py::TestHotdoc::test_implicit_conf_file" - "tests/test_hotdoc.py::TestHotdoc::test_private_folder" - ]; - disabledTests = [ # Test does not correctly handle path normalization for test comparison "test_cli_overrides" @@ -120,20 +100,6 @@ buildPythonApplication rec { "test_index" ]; - postPatch = - # Hardcode libclang paths - '' - substituteInPlace hotdoc/extensions/c/c_extension.py \ - --replace "shutil.which('llvm-config')" 'True' \ - --replace "subprocess.check_output(['llvm-config', '--version']).strip().decode()" '"${lib.versions.major llvmPackages.libclang.version}"' \ - --replace "subprocess.check_output(['llvm-config', '--prefix']).strip().decode()" '"${lib.getLib llvmPackages.libclang}"' \ - --replace "subprocess.check_output(['llvm-config', '--libdir']).strip().decode()" '"${lib.getLib llvmPackages.libclang}/lib"' - '' - # - + '' - patch -p1 -d cmark -i ${./fix-cmake-4.patch} - ''; - # Make pytest run from a temp dir to have it pick up installed package for cmark preCheck = '' pushd $TMPDIR diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 001ee576682d..8420aa185a95 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2505,7 +2505,7 @@ with pkgs; host = bind.host; - hotdoc = python3Packages.callPackage ../development/tools/hotdoc { }; + hotdoc = callPackage ../development/tools/hotdoc { }; hpccm = with python3Packages; toPythonApplication hpccm; From 00c938cad9fb1ad0f5e332811ea923879f2a1c7b Mon Sep 17 00:00:00 2001 From: TomaSajt <62384384+TomaSajt@users.noreply.github.com> Date: Tue, 5 May 2026 17:06:35 +0200 Subject: [PATCH 2/2] hotdoc: move to pkgs/by-name --- pkgs/{development/tools => by-name/ho}/hotdoc/clang.patch | 0 pkgs/{development/tools => by-name/ho}/hotdoc/fix-cmake-4.patch | 0 .../tools/hotdoc/default.nix => by-name/ho/hotdoc/package.nix} | 0 pkgs/top-level/all-packages.nix | 2 -- 4 files changed, 2 deletions(-) rename pkgs/{development/tools => by-name/ho}/hotdoc/clang.patch (100%) rename pkgs/{development/tools => by-name/ho}/hotdoc/fix-cmake-4.patch (100%) rename pkgs/{development/tools/hotdoc/default.nix => by-name/ho/hotdoc/package.nix} (100%) diff --git a/pkgs/development/tools/hotdoc/clang.patch b/pkgs/by-name/ho/hotdoc/clang.patch similarity index 100% rename from pkgs/development/tools/hotdoc/clang.patch rename to pkgs/by-name/ho/hotdoc/clang.patch diff --git a/pkgs/development/tools/hotdoc/fix-cmake-4.patch b/pkgs/by-name/ho/hotdoc/fix-cmake-4.patch similarity index 100% rename from pkgs/development/tools/hotdoc/fix-cmake-4.patch rename to pkgs/by-name/ho/hotdoc/fix-cmake-4.patch diff --git a/pkgs/development/tools/hotdoc/default.nix b/pkgs/by-name/ho/hotdoc/package.nix similarity index 100% rename from pkgs/development/tools/hotdoc/default.nix rename to pkgs/by-name/ho/hotdoc/package.nix diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8420aa185a95..51279ac2fd72 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2505,8 +2505,6 @@ with pkgs; host = bind.host; - hotdoc = callPackage ../development/tools/hotdoc { }; - hpccm = with python3Packages; toPythonApplication hpccm; html-proofer = callPackage ../tools/misc/html-proofer { };