Depends toolchain doesn't contain enough info to build from depends on a fresh NixOS install #32428

issue willcl-ark opened this issue on May 6, 2025
  1. willcl-ark commented at 3:31 PM on May 6, 2025: member

    Is there an existing issue for this?

    • I have searched the existing issues

    Current behaviour

    On a fresh NixOS install when building using depends, the generated toolchain does not pass along enough info for the depends packages to be found by cmake:

    • Following the reproduction steps below will cause cmake -B build --toolchain <toolchain> to error with:
    -- The CXX compiler identification is Clang 19.1.3
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: /nix/store/l4bagvaywzkq3cbjd98rjkqwc0vkpxxw-clang-wrapper-19.1.3/bin/clang++ - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Setting build type to "RelWithDebInfo" as none was specified
    -- Performing Test CXX_SUPPORTS__WERROR
    -- Performing Test CXX_SUPPORTS__WERROR - Success
    -- Performing Test CXX_SUPPORTS__G3
    -- Performing Test CXX_SUPPORTS__G3 - Success
    -- Performing Test LINKER_SUPPORTS__G3
    -- Performing Test LINKER_SUPPORTS__G3 - Success
    -- Performing Test CXX_SUPPORTS__FTRAPV
    -- Performing Test CXX_SUPPORTS__FTRAPV - Success
    -- Performing Test LINKER_SUPPORTS__FTRAPV
    -- Performing Test LINKER_SUPPORTS__FTRAPV - Success
    CMake Error at /nix/store/4kb60dy0dg80ww8gh2av4by4vwn8l48k-cmake-3.30.5/share/cmake-3.30/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
      Could NOT find SQLite3 (missing: SQLite3_INCLUDE_DIR SQLite3_LIBRARY)
      (Required is at least version "3.7.17")
    Call Stack (most recent call first):
      /nix/store/4kb60dy0dg80ww8gh2av4by4vwn8l48k-cmake-3.30.5/share/cmake-3.30/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
      /nix/store/4kb60dy0dg80ww8gh2av4by4vwn8l48k-cmake-3.30.5/share/cmake-3.30/Modules/FindSQLite3.cmake:66 (find_package_handle_standard_args)
      CMakeLists.txt:110 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    

    I have started some basic investigation of this and found that with this patch we can detect the depends libraries correctly and build successfully, but I am unsure if this is the correct approach for a fix.

    Expected behaviour

    The toolchain should pass along enough information so that packages can be located on a fresh system install.

    Steps to reproduce

    docker run --pull=always -it nixos/nix
    git clone --depth=1 https://github.com/bitcoin/bitcoin && cd bitcoin
    nix-shell -p binutils cmake curl gcc gitMinimal gnumake patch pkg-config python3
    make -C depends -j10 NO_QT=1
    cmake -B build --toolchain /bitcoin/depends/<host-platform-triplet>/toolchain.cmake
    

    Relevant log output

    <details><summary>Example of a generated toolchain</summary> <p>

    # Copyright (c) 2023-present The Bitcoin Core developers
    # Distributed under the MIT software license, see the accompanying
    # file COPYING or https://opensource.org/license/mit/.
    
    # This file is expected to be highly volatile and may still change substantially.
    
    # If CMAKE_SYSTEM_NAME is set within a toolchain file, CMake will also
    # set CMAKE_CROSSCOMPILING to TRUE, even if CMAKE_SYSTEM_NAME matches
    # CMAKE_HOST_SYSTEM_NAME. To avoid potential misconfiguration of CMake,
    # it is best not to touch CMAKE_SYSTEM_NAME unless cross-compiling is
    # intended.
    if(FALSE)
      set(CMAKE_SYSTEM_NAME Linux)
      set(CMAKE_SYSTEM_VERSION 3.17.0)
      set(CMAKE_SYSTEM_PROCESSOR x86_64)
    
      set(CMAKE_C_COMPILER_TARGET x86_64-pc-linux-gnu)
      set(CMAKE_CXX_COMPILER_TARGET x86_64-pc-linux-gnu)
      set(CMAKE_OBJCXX_COMPILER_TARGET x86_64-pc-linux-gnu)
    endif()
    
    if(NOT DEFINED CMAKE_C_FLAGS_INIT)
      set(CMAKE_C_FLAGS_INIT "-pipe -std=c11")
    endif()
    if(NOT DEFINED CMAKE_C_FLAGS_RELWITHDEBINFO_INIT)
      set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O2")
    endif()
    if(NOT DEFINED CMAKE_C_FLAGS_DEBUG_INIT)
      set(CMAKE_C_FLAGS_DEBUG_INIT "")
    endif()
    
    if(NOT DEFINED CMAKE_C_COMPILER)
      set(CMAKE_C_COMPILER clang)
    endif()
    
    if(NOT DEFINED CMAKE_CXX_FLAGS_INIT)
      set(CMAKE_CXX_FLAGS_INIT "-pipe -std=c++20")
      set(CMAKE_OBJCXX_FLAGS_INIT "-pipe -std=c++20")
    endif()
    if(NOT DEFINED CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT)
      set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2")
      set(CMAKE_OBJCXX_FLAGS_RELWITHDEBINFO_INIT "-O2")
    endif()
    if(NOT DEFINED CMAKE_CXX_FLAGS_DEBUG_INIT)
      set(CMAKE_CXX_FLAGS_DEBUG_INIT "")
      set(CMAKE_OBJCXX_FLAGS_DEBUG_INIT "")
    endif()
    
    if(NOT DEFINED CMAKE_CXX_COMPILER)
      set(CMAKE_CXX_COMPILER clang++)
      set(CMAKE_OBJCXX_COMPILER ${CMAKE_CXX_COMPILER})
    endif()
    
    # The DEPENDS_COMPILE_DEFINITIONS* variables are to be treated as lists.
    set(DEPENDS_COMPILE_DEFINITIONS )
    set(DEPENDS_COMPILE_DEFINITIONS_RELWITHDEBINFO )
    set(DEPENDS_COMPILE_DEFINITIONS_DEBUG )
    
    if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_INIT)
      set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=mold")
    endif()
    if(NOT DEFINED CMAKE_SHARED_LINKER_FLAGS_INIT)
      set(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=mold")
    endif()
    if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT)
      set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "")
    endif()
    if(NOT DEFINED CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT)
      set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT "")
    endif()
    if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT)
      set(CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "")
    endif()
    if(NOT DEFINED CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT)
      set(CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT "")
    endif()
    
    set(CMAKE_AR "ar")
    set(CMAKE_RANLIB "ranlib")
    set(CMAKE_STRIP "strip")
    set(CMAKE_OBJCOPY "objcopy")
    set(CMAKE_OBJDUMP "objdump")
    
    # Using our own built dependencies should not be
    # affected by a potentially random environment.
    set(CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH OFF)
    
    set(CMAKE_FIND_ROOT_PATH "${CMAKE_CURRENT_LIST_DIR}")
    set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
    set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
    set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
    set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
    set(QT_TRANSLATIONS_DIR "${CMAKE_CURRENT_LIST_DIR}/translations")
    
    if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE)
      # The find_package(Qt ...) function internally uses find_library()
      # calls for all dependencies to ensure their availability.
      # In turn, the find_library() inspects the well-known locations
      # on the file system; therefore, a hint is required.
      set(CMAKE_FRAMEWORK_PATH "/System/Library/Frameworks")
    endif()
    
    
    if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
      # Customize pkg-config behavior for finding dependencies
      # of the xcb QPA platform plugin:
      # 1. Restrict search paths to the depends.
      # 2. Make output suitable for static linking.
      cmake_path(APPEND CMAKE_CURRENT_LIST_DIR "lib" "pkgconfig" OUTPUT_VARIABLE pkg_config_path)
      set(ENV{PKG_CONFIG_PATH} ${pkg_config_path})
      set(ENV{PKG_CONFIG_LIBDIR} ${pkg_config_path})
      unset(pkg_config_path)
      set(PKG_CONFIG_ARGN --static)
    endif()
    
    
    # Set configuration options for the main build system.
    set(qt_packages  qt expat libxcb xcb_proto libXau xproto freetype fontconfig libxkbcommon libxcb_util libxcb_util_cursor libxcb_util_render libxcb_util_keysyms libxcb_util_image libxcb_util_wm  qrencode)
    if("${qt_packages}" STREQUAL "")
      set(BUILD_GUI OFF CACHE BOOL "")
    else()
      set(BUILD_GUI ON CACHE BOOL "")
      set(Qt6_ROOT "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "")
    endif()
    
    set(qrencode_packages qrencode)
    if("${qrencode_packages}" STREQUAL "")
      set(WITH_QRENCODE OFF CACHE BOOL "")
    else()
      set(WITH_QRENCODE ON CACHE BOOL "")
    endif()
    
    set(zmq_packages zeromq)
    if("${zmq_packages}" STREQUAL "")
      set(WITH_ZMQ OFF CACHE BOOL "")
    else()
      set(WITH_ZMQ ON CACHE BOOL "")
    endif()
    
    set(wallet_packages bdb sqlite)
    if("${wallet_packages}" STREQUAL "")
      set(ENABLE_WALLET OFF CACHE BOOL "")
    else()
      set(ENABLE_WALLET ON CACHE BOOL "")
    endif()
    
    set(bdb_packages bdb)
    if("${wallet_packages}" STREQUAL "" OR "${bdb_packages}" STREQUAL "")
      set(WITH_BDB OFF CACHE BOOL "")
    else()
      set(WITH_BDB ON CACHE BOOL "")
    endif()
    
    set(usdt_packages systemtap)
    if("${usdt_packages}" STREQUAL "")
      set(WITH_USDT OFF CACHE BOOL "")
    else()
      set(WITH_USDT ON CACHE BOOL "")
    endif()
    
    if("" STREQUAL "1")
      set(ENABLE_IPC ON CACHE BOOL "")
      set(MPGEN_EXECUTABLE "${CMAKE_CURRENT_LIST_DIR}/native/bin/mpgen" CACHE FILEPATH "")
      set(CAPNP_EXECUTABLE "${CMAKE_CURRENT_LIST_DIR}/native/bin/capnp" CACHE FILEPATH "")
      set(CAPNPC_CXX_EXECUTABLE "${CMAKE_CURRENT_LIST_DIR}/native/bin/capnpc-c++" CACHE FILEPATH "")
    else()
      set(ENABLE_IPC OFF CACHE BOOL "")
    endif()
    

    </p> </details>

    <details><summary>Example cmake cache</summary> <p>

    # This is the CMakeCache file.
    # For build in directory: /home/will/src/core/bitcoin/build
    # It was generated by CMake: /nix/store/4kb60dy0dg80ww8gh2av4by4vwn8l48k-cmake-3.30.5/bin/cmake
    # You can edit this file to change values found and used by cmake.
    # If you do not want to change any of the values, simply exit the editor.
    # If you do want to change a value, simply edit, save, and exit the editor.
    # The syntax for the file is as follows:
    # KEY:TYPE=VALUE
    # KEY is the name of a variable in the cache.
    # TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!.
    # VALUE is the current value for the KEY.
    
    ########################
    # EXTERNAL cache entries
    ########################
    
    //Build bitcoin-cli executable.
    BUILD_CLI:BOOL=ON
    
    //Build bitcoind executable.
    BUILD_DAEMON:BOOL=ON
    
    //Build bitcoin-qt executable.
    BUILD_GUI:BOOL=ON
    
    //Build experimental bitcoinkernel library.
    BUILD_KERNEL_LIB:BOOL=OFF
    
    //Build test_bitcoin and other unit test executables.
    BUILD_TESTS:BOOL=ON
    
    //Build bitcoin-tx executable.
    BUILD_TX:BOOL=ON
    
    //Build bitcoin-util executable.
    BUILD_UTIL:BOOL=ON
    
    //Build experimental bitcoin-chainstate executable.
    BUILD_UTIL_CHAINSTATE:BOOL=OFF
    
    //Value Computed by CMake
    BitcoinCore_BINARY_DIR:STATIC=/home/will/src/core/bitcoin/build
    
    //Value Computed by CMake
    BitcoinCore_IS_TOP_LEVEL:STATIC=ON
    
    //Value Computed by CMake
    BitcoinCore_SOURCE_DIR:STATIC=/home/will/src/core/bitcoin
    
    //Path to a program.
    CMAKE_ADDR2LINE:FILEPATH=/nix/store/l4bagvaywzkq3cbjd98rjkqwc0vkpxxw-clang-wrapper-19.1.3/bin/addr2line
    
    //Choose the type of build, options are: None Debug Release RelWithDebInfo
    // MinSizeRel ...
    CMAKE_BUILD_TYPE:STRING=RelWithDebInfo
    
    //LLVM archiver
    CMAKE_CXX_COMPILER_AR:FILEPATH=CMAKE_CXX_COMPILER_AR-NOTFOUND
    
    //`clang-scan-deps` dependency scanner
    CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS:FILEPATH=/nix/store/zld513b4myr3yhs4yyjrcaxag5fcgd57-clang-tools-19.1.3/bin/clang-scan-deps
    
    //Generate index for LLVM archive
    CMAKE_CXX_COMPILER_RANLIB:FILEPATH=CMAKE_CXX_COMPILER_RANLIB-NOTFOUND
    
    //Flags used by the CXX compiler during all build types.
    CMAKE_CXX_FLAGS:STRING=-pipe -std=c++20
    
    //Flags used by the CXX compiler during DEBUG builds.
    CMAKE_CXX_FLAGS_DEBUG:STRING=-O0 -ftrapv -g3
    
    //Flags used by the CXX compiler during MINSIZEREL builds.
    CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os
    
    //Flags used by the CXX compiler during RELEASE builds.
    CMAKE_CXX_FLAGS_RELEASE:STRING=-O2
    
    //Flags used by the CXX compiler during RELWITHDEBINFO builds.
    CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -O2 -g
    
    //Path to a program.
    CMAKE_DLLTOOL:FILEPATH=CMAKE_DLLTOOL-NOTFOUND
    
    //Flags used by the linker during all build types.
    CMAKE_EXE_LINKER_FLAGS:STRING=-fuse-ld=mold -fuse-ld=mold
    
    //Flags used by the linker during DEBUG builds.
    CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=
    
    //Flags used by the linker during MINSIZEREL builds.
    CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=
    
    //Flags used by the linker during RELEASE builds.
    CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=
    
    //Flags used by the linker during RELWITHDEBINFO builds.
    CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
    
    //Enable/Disable output of compile commands during generation.
    CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=1
    
    //Value Computed by CMake.
    CMAKE_FIND_PACKAGE_REDIRECTS_DIR:STATIC=/home/will/src/core/bitcoin/build/CMakeFiles/pkgRedirects
    
    //Install path prefix, prepended onto install directories.
    CMAKE_INSTALL_PREFIX:PATH=/var/empty/local
    
    //Path to a program.
    CMAKE_LINKER:FILEPATH=/nix/store/l4bagvaywzkq3cbjd98rjkqwc0vkpxxw-clang-wrapper-19.1.3/bin/ld
    
    //Program used to build from build.ninja files.
    CMAKE_MAKE_PROGRAM:FILEPATH=/nix/store/nwsn9hg84pf9rpy3bgdpssa2b6qc7w3p-ninja-1.12.1/bin/ninja
    
    //Flags used by the linker during the creation of modules during
    // all build types.
    CMAKE_MODULE_LINKER_FLAGS:STRING=-fuse-ld=mold
    
    //Flags used by the linker during the creation of modules during
    // DEBUG builds.
    CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=
    
    //Flags used by the linker during the creation of modules during
    // MINSIZEREL builds.
    CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=
    
    //Flags used by the linker during the creation of modules during
    // RELEASE builds.
    CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=
    
    //Flags used by the linker during the creation of modules during
    // RELWITHDEBINFO builds.
    CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
    
    //Path to a program.
    CMAKE_NM:FILEPATH=/nix/store/l4bagvaywzkq3cbjd98rjkqwc0vkpxxw-clang-wrapper-19.1.3/bin/nm
    
    //Value Computed by CMake
    CMAKE_PROJECT_DESCRIPTION:STATIC=Bitcoin client software
    
    //Value Computed by CMake
    CMAKE_PROJECT_HOMEPAGE_URL:STATIC=https://bitcoincore.org/
    
    //Value Computed by CMake
    CMAKE_PROJECT_NAME:STATIC=BitcoinCore
    
    //Value Computed by CMake
    CMAKE_PROJECT_VERSION:STATIC=29.99.0
    
    //Value Computed by CMake
    CMAKE_PROJECT_VERSION_MAJOR:STATIC=29
    
    //Value Computed by CMake
    CMAKE_PROJECT_VERSION_MINOR:STATIC=99
    
    //Value Computed by CMake
    CMAKE_PROJECT_VERSION_PATCH:STATIC=0
    
    //Value Computed by CMake
    CMAKE_PROJECT_VERSION_TWEAK:STATIC=
    
    //Path to a program.
    CMAKE_READELF:FILEPATH=/nix/store/l4bagvaywzkq3cbjd98rjkqwc0vkpxxw-clang-wrapper-19.1.3/bin/readelf
    
    //Flags used by the linker during the creation of shared libraries
    // during all build types.
    CMAKE_SHARED_LINKER_FLAGS:STRING=-fuse-ld=mold -fuse-ld=mold
    
    //Flags used by the linker during the creation of shared libraries
    // during DEBUG builds.
    CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=
    
    //Flags used by the linker during the creation of shared libraries
    // during MINSIZEREL builds.
    CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=
    
    //Flags used by the linker during the creation of shared libraries
    // during RELEASE builds.
    CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=
    
    //Flags used by the linker during the creation of shared libraries
    // during RELWITHDEBINFO builds.
    CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=
    
    //If set, runtime paths are not added when installing shared libraries,
    // but are added when building.
    CMAKE_SKIP_INSTALL_RPATH:BOOL=NO
    
    //If set, runtime paths are not added when using shared libraries.
    CMAKE_SKIP_RPATH:BOOL=NO
    
    //Flags used by the linker during the creation of static libraries
    // during all build types.
    CMAKE_STATIC_LINKER_FLAGS:STRING=
    
    //Flags used by the linker during the creation of static libraries
    // during DEBUG builds.
    CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING=
    
    //Flags used by the linker during the creation of static libraries
    // during MINSIZEREL builds.
    CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING=
    
    //Flags used by the linker during the creation of static libraries
    // during RELEASE builds.
    CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING=
    
    //Flags used by the linker during the creation of static libraries
    // during RELWITHDEBINFO builds.
    CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING=
    
    //Path to a program.
    CMAKE_TAPI:FILEPATH=CMAKE_TAPI-NOTFOUND
    
    //The CMake toolchain file
    CMAKE_TOOLCHAIN_FILE:FILEPATH=/home/will/src/core/bitcoin/depends/x86_64-pc-linux-gnu/toolchain.cmake
    
    //If this value is on, makefiles will be generated without the
    // .SILENT directive, and all commands will be echoed to the console
    // during the make.  This is useful for debugging only. With Visual
    // Studio IDE projects all commands are done without /nologo.
    CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
    
    ENABLE_IPC:BOOL=OFF
    
    //Enable wallet.
    ENABLE_WALLET:BOOL=ON
    
    //Arguments to supply to pkg-config
    PKG_CONFIG_ARGN:STRING=--static
    
    //pkg-config executable
    PKG_CONFIG_EXECUTABLE:FILEPATH=/nix/store/f1gamyykr0f8n4afy910ass2jx2g9zkv-pkg-config-wrapper-0.29.2/bin/pkg-config
    
    Qt6_ROOT:PATH=/home/will/src/core/bitcoin/depends/x86_64-pc-linux-gnu
    
    //Path to a file.
    SQLite3_INCLUDE_DIR:PATH=SQLite3_INCLUDE_DIR-NOTFOUND
    
    //Path to a library.
    SQLite3_LIBRARY:FILEPATH=SQLite3_LIBRARY-NOTFOUND
    
    WITH_BDB:BOOL=ON
    
    WITH_QRENCODE:BOOL=ON
    
    WITH_USDT:BOOL=ON
    
    WITH_ZMQ:BOOL=ON
    
    
    ########################
    # INTERNAL cache entries
    ########################
    
    //ADVANCED property for variable: CMAKE_ADDR2LINE
    CMAKE_ADDR2LINE-ADVANCED:INTERNAL=1
    //STRINGS property for variable: CMAKE_BUILD_TYPE
    CMAKE_BUILD_TYPE-STRINGS:INTERNAL=RelWithDebInfo;Debug;Release;MinSizeRel
    //This is the directory where this CMakeCache.txt was created
    CMAKE_CACHEFILE_DIR:INTERNAL=/home/will/src/core/bitcoin/build
    //Major version of cmake used to create the current loaded cache
    CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
    //Minor version of cmake used to create the current loaded cache
    CMAKE_CACHE_MINOR_VERSION:INTERNAL=30
    //Patch version of cmake used to create the current loaded cache
    CMAKE_CACHE_PATCH_VERSION:INTERNAL=5
    //Path to CMake executable.
    CMAKE_COMMAND:INTERNAL=/nix/store/4kb60dy0dg80ww8gh2av4by4vwn8l48k-cmake-3.30.5/bin/cmake
    //Path to cpack program executable.
    CMAKE_CPACK_COMMAND:INTERNAL=/nix/store/4kb60dy0dg80ww8gh2av4by4vwn8l48k-cmake-3.30.5/bin/cpack
    //Path to ctest program executable.
    CMAKE_CTEST_COMMAND:INTERNAL=/nix/store/4kb60dy0dg80ww8gh2av4by4vwn8l48k-cmake-3.30.5/bin/ctest
    //ADVANCED property for variable: CMAKE_CXX_COMPILER_AR
    CMAKE_CXX_COMPILER_AR-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS
    CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_CXX_COMPILER_RANLIB
    CMAKE_CXX_COMPILER_RANLIB-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_CXX_FLAGS
    CMAKE_CXX_FLAGS-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_CXX_FLAGS_DEBUG
    CMAKE_CXX_FLAGS_DEBUG-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_CXX_FLAGS_MINSIZEREL
    CMAKE_CXX_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_CXX_FLAGS_RELEASE
    CMAKE_CXX_FLAGS_RELEASE-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_CXX_FLAGS_RELWITHDEBINFO
    CMAKE_CXX_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_DLLTOOL
    CMAKE_DLLTOOL-ADVANCED:INTERNAL=1
    //Executable file format
    CMAKE_EXECUTABLE_FORMAT:INTERNAL=ELF
    //ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS
    CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG
    CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL
    CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE
    CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
    CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_EXPORT_COMPILE_COMMANDS
    CMAKE_EXPORT_COMPILE_COMMANDS-ADVANCED:INTERNAL=1
    //Name of external makefile project generator.
    CMAKE_EXTRA_GENERATOR:INTERNAL=
    //Name of generator.
    CMAKE_GENERATOR:INTERNAL=Ninja
    //Generator instance identifier.
    CMAKE_GENERATOR_INSTANCE:INTERNAL=
    //Name of generator platform.
    CMAKE_GENERATOR_PLATFORM:INTERNAL=
    //Name of generator toolset.
    CMAKE_GENERATOR_TOOLSET:INTERNAL=
    //Source directory with the top level CMakeLists.txt file for this
    // project
    CMAKE_HOME_DIRECTORY:INTERNAL=/home/will/src/core/bitcoin
    //Install .so files without execute permission.
    CMAKE_INSTALL_SO_NO_EXE:INTERNAL=0
    //ADVANCED property for variable: CMAKE_LINKER
    CMAKE_LINKER-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_MAKE_PROGRAM
    CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS
    CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG
    CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
    CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE
    CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
    CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_NM
    CMAKE_NM-ADVANCED:INTERNAL=1
    //number of local generators
    CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=1
    //Platform information initialized
    CMAKE_PLATFORM_INFO_INITIALIZED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_READELF
    CMAKE_READELF-ADVANCED:INTERNAL=1
    //Path to CMake installation.
    CMAKE_ROOT:INTERNAL=/nix/store/4kb60dy0dg80ww8gh2av4by4vwn8l48k-cmake-3.30.5/share/cmake-3.30
    //ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS
    CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG
    CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
    CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE
    CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
    CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_SKIP_INSTALL_RPATH
    CMAKE_SKIP_INSTALL_RPATH-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_SKIP_RPATH
    CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS
    CMAKE_STATIC_LINKER_FLAGS-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_DEBUG
    CMAKE_STATIC_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL
    CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELEASE
    CMAKE_STATIC_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO
    CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: CMAKE_TAPI
    CMAKE_TAPI-ADVANCED:INTERNAL=1
    //uname command
    CMAKE_UNAME:INTERNAL=/nix/store/k48bha2fjqzarg52picsdfwlqx75aqbb-coreutils-9.5/bin/uname
    //ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE
    CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1
    //Test CXX_SUPPORTS__FTRAPV
    CXX_SUPPORTS__FTRAPV:INTERNAL=1
    //Test CXX_SUPPORTS__G3
    CXX_SUPPORTS__G3:INTERNAL=1
    //Test CXX_SUPPORTS__WERROR
    CXX_SUPPORTS__WERROR:INTERNAL=1
    //Test LINKER_SUPPORTS__FTRAPV
    LINKER_SUPPORTS__FTRAPV:INTERNAL=1
    //Test LINKER_SUPPORTS__G3
    LINKER_SUPPORTS__G3:INTERNAL=1
    PC_SQLite3_CFLAGS:INTERNAL=
    PC_SQLite3_CFLAGS_I:INTERNAL=
    PC_SQLite3_CFLAGS_OTHER:INTERNAL=
    PC_SQLite3_FOUND:INTERNAL=
    PC_SQLite3_INCLUDEDIR:INTERNAL=
    PC_SQLite3_LIBDIR:INTERNAL=
    PC_SQLite3_LIBS:INTERNAL=
    PC_SQLite3_LIBS_L:INTERNAL=
    PC_SQLite3_LIBS_OTHER:INTERNAL=
    PC_SQLite3_LIBS_PATHS:INTERNAL=
    PC_SQLite3_MODULE_NAME:INTERNAL=
    PC_SQLite3_PREFIX:INTERNAL=
    PC_SQLite3_STATIC_CFLAGS:INTERNAL=
    PC_SQLite3_STATIC_CFLAGS_I:INTERNAL=
    PC_SQLite3_STATIC_CFLAGS_OTHER:INTERNAL=
    PC_SQLite3_STATIC_LIBDIR:INTERNAL=
    PC_SQLite3_STATIC_LIBS:INTERNAL=
    PC_SQLite3_STATIC_LIBS_L:INTERNAL=
    PC_SQLite3_STATIC_LIBS_OTHER:INTERNAL=
    PC_SQLite3_STATIC_LIBS_PATHS:INTERNAL=
    PC_SQLite3_VERSION:INTERNAL=
    PC_SQLite3_sqlite3_INCLUDEDIR:INTERNAL=
    PC_SQLite3_sqlite3_LIBDIR:INTERNAL=
    PC_SQLite3_sqlite3_PREFIX:INTERNAL=
    PC_SQLite3_sqlite3_VERSION:INTERNAL=
    //ADVANCED property for variable: PKG_CONFIG_ARGN
    PKG_CONFIG_ARGN-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: PKG_CONFIG_EXECUTABLE
    PKG_CONFIG_EXECUTABLE-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: SQLite3_INCLUDE_DIR
    SQLite3_INCLUDE_DIR-ADVANCED:INTERNAL=1
    //ADVANCED property for variable: SQLite3_LIBRARY
    SQLite3_LIBRARY-ADVANCED:INTERNAL=1
    //linker supports push/pop state
    _CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED:INTERNAL=FALSE
    __pkg_config_checked_PC_SQLite3:INTERNAL=1
    

    </p> </details>

    How did you obtain Bitcoin Core

    Compiled from source

    What version of Bitcoin Core are you using?

    master@885b4bc8b59d1cbbaea519207f715eab447cc0ff

    Operating system and version

    NixOS 25.05 (Warbler) x86_64

    Machine specifications

    No response

  2. hebasto added the label Build system on May 6, 2025
  3. ryanofsky commented at 3:49 PM on May 6, 2025: contributor

    I debugged this issue at some point before and have been working around it since by setting the PATH variable when using depends like:

    export PATH=$PATH:$PWD/depends/x86_64-pc-linux-gnu/include
    export PATH=$PATH:$PWD/depends/x86_64-pc-linux-gnu/lib
    cmake -B build -DCMAKE_TOOLCHAIN_FILE=depends/x86_64-pc-linux-gnu/toolchain.cmake
    

    More ideally, we would be able to do:

    export CMAKE_PREFIX_PATH=$PWD/depends/x86_64-pc-linux-gnu
    cmake -B build -DCMAKE_TOOLCHAIN_FILE=depends/x86_64-pc-linux-gnu/toolchain.cmake
    

    but this only works if you delete set(CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH OFF) from the toolchain file:

    https://github.com/bitcoin/bitcoin/blob/baa848b8d38187ce6b24a57cfadf1ea180209711/depends/toolchain.cmake.in#L86

    I commented on this previously in #30940#pullrequestreview-2322355196


    EDIT: Just noticed suggested fix 437a4da93f437f9588ff32d19ac59fea3802c676. That is probably better than either of two workarounds I suggested above.

    EDIT 2: I guess my PATH hack above worked because we are only turning off the CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH option but not the CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH option

  4. hebasto commented at 4:23 PM on May 6, 2025: member
  5. hebasto commented at 4:30 PM on May 6, 2025: member

    The problem is caused by set(CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH OFF) in the toolchain file:

    https://github.com/bitcoin/bitcoin/blob/baa848b8d38187ce6b24a57cfadf1ea180209711/depends/toolchain.cmake.in#L86

    and I believe it goes away if you remove that line. I commented on this previously in #30940 (review)

    Here is some additional context on how this code was introduced: https://github.com/hebasto/bitcoin/pull/88#discussion_r1471043621.

  6. hebasto referenced this in commit 546adfdfc6 on May 6, 2025
  7. ryanofsky commented at 5:58 PM on May 6, 2025: contributor

    I can confirm Will's commit in 437a4da93f437f9588ff32d19ac59fea3802c676 fixes the problem for me and seems like a good solution. But I think it can be simplified to only just list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}") and the if() guard should be unnecessary.

    I also confirmed the other fix appending -DCMAKE_PREFIX_PATH=/ to the command line from https://github.com/hebasto/bitcoin/issues/121#issuecomment-2015274066 works. I guess this works because cmake appends CMAKE_FIND_ROOT_PATH to CMAKE_PREFIX_PATH when searching.

    I also confirmed adding -DCMAKE_PREFIX_PATH=$PWD/depends/x86_64-pc-linux-gnu to the command line works.

    And I confirmed adding list(APPEND CMAKE_PREFIX_PATH "/") to the toolchain file works as well.

    I also tried my PATH workaround again and it works for sqlite but then it fails to find zmq and libevent packages unless also adding -DCMAKE_PREFIX_PATH=$PWD/depends/x86_64-pc-linux-gnu/lib/cmake with unnecessary lib/cmake suffix (which I guess was my original approach which led finding that workaround).

    In any case, it seems like a good fix could just be to add list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}") to the toolchain file and be done.

    The thing I don't understand is why setting CMAKE_PREFIX_PATH as well as CMAKE_FIND_ROOT_PATH seems to be necessary on nix while setting CMAKE_FIND_ROOT_PATH alone seems to work on other platforms.

  8. ryanofsky commented at 7:08 PM on May 6, 2025: contributor

    The thing I don't understand is why setting CMAKE_PREFIX_PATH as well as CMAKE_FIND_ROOT_PATH seems to be necessary on nix while setting CMAKE_FIND_ROOT_PATH alone seems to work on other platforms.

    Reason for this is that nix is patching cmake to remove the root path / from CMAKE_SYSTEM_PREFIX_PATH in https://github.com/NixOS/nixpkgs/blob/df545660856d8252b4856bede70d424ef4b47c64/pkgs/by-name/cm/cmake/001-search-path.diff

    Because of this CMAKE_FIND_ROOT_PATH is not searched directly for dependencies and setting CMAKE_PREFIX_PATH just compensates by telling it where else too look.

    (Found answer to this question by asking chatgpt O3 which was able to point directly at the patch. Otherwise I would have no idea.)

    So I think the following might be the most direct fix.

    --- a/depends/toolchain.cmake.in
    +++ b/depends/toolchain.cmake.in
    @@ -92,6 +92,14 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
     set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
     set(QT_TRANSLATIONS_DIR "${CMAKE_CURRENT_LIST_DIR}/translations")
     
    +# Following is only necessary when using cmake from Nix or NixOS, because Nix
    +# patches cmake to remove the root directory `/` from CMAKE_SYSTEM_PREFIX_PATH.
    +# Adding it back is harmless on other platforms and necessary on Nix because
    +# without it cmake find_path, find_package, etc functions do not know where to
    +# look in CMAKE_FIND_ROOT_PATH for dependencies
    +# (https://github.com/bitcoin/bitcoin/issues/32428).
    +list(APPEND CMAKE_SYSTEM_PREFIX_PATH "/")
    +
     if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE)
       # The find_package(Qt ...) function internally uses find_library()
       # calls for all dependencies to ensure their availability.
    
  9. willcl-ark commented at 7:11 PM on May 6, 2025: member

    Yes I agree @ryanofsky, thanks for double-checking!

    I added the if() guard because I heard from [@hebasto](/bitcoin-bitcoin/contributor/hebasto/) that we call the toolchain multiple times, and the if guard therefore avoids adding the path repeatedly.

  10. ryanofsky commented at 7:23 PM on May 6, 2025: contributor

    I added the if() guard because I heard from @hebasto that we call the toolchain multiple times, and the if guard therefore avoids adding the path repeatedly.

    I think this is half-true. I noticed by adding prints to the cmake file that it was called multiple times, but each time CMAKE_PREFIX_PATH was always set back to the original value, so I don't think the if guard did anything.

    Also just to be sure another difference isn't glossed over: I think it probably is better to set CMAKE_SYSTEM_PREFIX_PATH instead of CMAKE_PREFIX_PATH since former seems to fix the original problem, while latter is more of a workaround.

    Also really appreciate you reporting this issue and finding a good workaround. This has been causing me headaches for a long time, and I've only had crappy workarounds and couldn't figure out how this was working at all on other systems.

  11. willcl-ark commented at 7:46 PM on May 6, 2025: member

    Also just to be sure another difference isn't glossed over: I think it probably is better to set CMAKE_SYSTEM_PREFIX_PATH instead of CMAKE_PREFIX_PATH since former seems to fix the original problem, while latter is more of a workaround.

    That sounds reasonable.

    Also really appreciate you reporting this issue and finding a good workaround. This has been causing me headaches for a long time, and I've only had crappy workarounds and couldn't figure out how this was working at all on other systems.

    I'm glad I did! I only recently switched to NixOS and was about to go around start bugging other known Nix users about "how they got depends working" as it's been driving me a bit mad too :D

    I've got another half-baked patch which I also appear to need to actually make a depends-built bitcoin-qt work under NixOS: https://github.com/bitcoin/bitcoin/commit/3700c49e57faf2e0eb9bdae0526004ebf4ee343e I'd like to investigate if I can fix it up using LDPRELOAD rather than requiring a custom RPATH toggle (just for NixOS!), but I think I'm gunna leave that for another day... 😄

  12. willcl-ark referenced this in commit 12966ca13a on May 6, 2025
  13. willcl-ark referenced this in commit fa4b7f4cd5 on May 6, 2025
  14. hebasto referenced this in commit ea799dece3 on May 6, 2025
  15. hebasto commented at 9:22 PM on May 6, 2025: member

    I added the if() guard because I heard from @hebasto that we call the toolchain multiple times, and the if guard therefore avoids adding the path repeatedly.

    I think this is half-true. I noticed by adding prints to the cmake file that it was called multiple times, but each time CMAKE_PREFIX_PATH was always set back to the original value, so I don't think the if guard did anything.

    I'd avoid making assumptions about undocumented CMAKE_PREFIX_PATH-related behaviour. Let's preserve the idempotence of the toolchain file.

  16. hebasto commented at 6:44 AM on May 7, 2025: member

    The problem is caused by set(CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH OFF) in the toolchain file:

    bitcoin/depends/toolchain.cmake.in](https://github.com/bitcoin/bitcoin/blob/baa848b8d38187ce6b24a57cfadf1ea180209711/depends/toolchain.cmake.in#L86

    and I believe it goes away if you remove that line. I commented on this previously in #30940 (review)

    Here is some additional context on how this code was introduced: hebasto#88 (comment).

    I've re-verified this on the current master branch: set(CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH OFF) is no longer necessary for Guix builds following the migration to Qt 6.

    UPD. I'm not suggesting removing this command. See #32428 (comment).

  17. hebasto commented at 6:57 AM on May 7, 2025: member
  18. willcl-ark commented at 9:01 AM on May 7, 2025: member

    I have just re-tested and do not find that removing CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH sees the depends toolchain working correctly on a default NixOS install, using the repro steps in OP.

    I'd avoid making assumptions about undocumented CMAKE_PREFIX_PATH-related behaviour. Let's preserve the idempotence of the toolchain file.

    Am I correctly understanding therefore that you are suggesting for the following changes as a fix for this?:

    1. Remove CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH
    2. Explicitly set CMAKE_PREFIX_PATH using an if-guard, as per: https://github.com/bitcoin/bitcoin/commit/437a4da93f437f9588ff32d19ac59fea3802c676
  19. hebasto commented at 9:13 AM on May 7, 2025: member

    Am I correctly understanding therefore that you are suggesting for the following changes as a fix for this?:

    1. Remove CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH

    Building our own depends implies that we fully rely on them, ideally skipping all other search paths used by CMake's package, library, and header search mechanisms. Therefore, I believe we should retain as many restrictions as possible.

    1. Explicitly set CMAKE_PREFIX_PATH using an if-guard, as per: 437a4da

    Any list appending we agree on should be if-guarded.

  20. purpleKarrot commented at 9:45 PM on May 7, 2025: contributor

    Building our own depends implies that we fully rely on them, ideally skipping all other search paths used by CMake's package, library, and header search mechanisms. Therefore, I believe we should retain as many restrictions as possible.

    We may do that with a dependency provider. This will put find_package() completely under our control, so restricting CMake's builtin find logic becomes unnecessary.

  21. hebasto commented at 9:32 AM on May 8, 2025: member

    Building our own depends implies that we fully rely on them, ideally skipping all other search paths used by CMake's package, library, and header search mechanisms. Therefore, I believe we should retain as many restrictions as possible.

    We may do that with a dependency provider. This will put find_package() completely under our control, so restricting CMake's builtin find logic becomes unnecessary.

    Does this require a minimum CMake version of 3.24?

  22. purpleKarrot commented at 10:54 AM on May 8, 2025: contributor

    We may do that with a dependency provider. This will put find_package() completely under our control, so restricting CMake's builtin find logic becomes unnecessary.

    Does this require a minimum CMake version of 3.24?

    Yes, but it does not require updating the minimum required version of the project. That means building with system packages would be possible with version 3.22, while building with depends would require 3.24.

  23. willcl-ark commented at 1:16 PM on May 15, 2025: member

    OK I've taken a first stab at implementing this and the provider sounds like a tidy fix...

    My current branch is here: https://github.com/bitcoin/bitcoin/compare/master...willcl-ark:bitcoin:cmake-depdency-provider

    It appears to work quite nicely, for a single host build on NixOS, so long as QT is excluded, at least. (I can't seem to get the provider to pick up the various XCB components from Qt properly, and a bit lost on how to proceed with this now).

  24. willcl-ark commented at 2:08 PM on May 16, 2025: member

    OK I updated that branch a little, it is now simplified, and works for Qt. However I did have to carve out Boost (bypassing the provider), for reasons that are not totally clear to me still.

  25. josibake commented at 12:00 PM on June 20, 2025: member

    Following suggestions from @willcl-ark , @ryanofsky and @hebasto , I've been testing this patch (which is just a slight modification of @ryanofsky 's):

    --- a/depends/toolchain.cmake.in
    +++ b/depends/toolchain.cmake.in
    @@ -92,6 +92,23 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
     set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
     set(QT_TRANSLATIONS_DIR "${CMAKE_CURRENT_LIST_DIR}/translations")
    
    +# Following is only necessary when using cmake from Nix or NixOS, because Nix
    +# patches cmake to remove the root directory `/` from CMAKE_SYSTEM_PREFIX_PATH.
    +# Adding it back is harmless on other platforms and necessary on Nix because
    +# without it cmake find_path, find_package, etc functions do not know where to
    +# look in CMAKE_FIND_ROOT_PATH for dependencies
    +# (https://github.com/bitcoin/bitcoin/issues/32428).
    +#
    +# TODO: longer term, it may be possible to use a dependency provider, which
    +# would bring the find_package calls completely under our control, making this
    +# patch unnecessary.
    +#
    +# Make sure we only append once, as this file may be called repeatedly.
    +list(FIND CMAKE_SYSTEM_PREFIX_PATH "/" _nix_idx)
    +if(_nix_idx EQUAL -1)
    +  list(APPEND CMAKE_SYSTEM_PREFIX_PATH "/")
    +endif()
    +
     if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE)
       # The find_package(Qt ...) function internally uses find_library()
       # calls for all dependencies to ensure their availability.
    
    

    Using this, I was able to get @0xB10C 's https://github.com/0xb10c/bitcoind-gunix cmake branch working and confirmed this also works for the nix development shell I've been working on, https://github.com/bitcoin-dev-tools/bix. By working, I mean:

    1. Can build from depends in a nix environment that only has the required dependencies for just the depends system
    2. Can build from depends in a nix environment that has all of the runtime / build dependencies for core, ensuring that only the depends dependencies are used

    Given how simple the patch is, I'd recommend we PR this patch as a way of unblocking nix / nixos users. This patch can and should be replaced if/when a more comprehensive dependency provider solution is deemed viable, which is why I extend @ryanofsky 's comment to mention this.

    I do think adding this patch is worth it, despite NixOS not being an "officially" supported platform, considering the nix package manager can be used on linux and macOS. Hence, I see this more as improving support for our existing platforms. Alternatively, we could just document that if someone wants to use Nix, they can pass -DCMAKE_PREFIX_PATH=/ as a work around.


    Longer term, based on my limited understanding, the dependency provider approach seems like the correct way to go. I did a bunch of testing on #32595 , but I'll add my thoughts on that PR (vs adding them here).

  26. willcl-ark commented at 2:05 PM on June 20, 2025: member

    @josibake I also prefer this approach of a non-intrusive quick-fix first, followed by a comprehensive dependency provider in the future. I've closed #32595 for now (and marked it up for grabs)

  27. willcl-ark referenced this in commit fbf7e1cf5a on Jun 23, 2025
  28. willcl-ark referenced this in commit 629f00e0b4 on Jun 23, 2025
  29. willcl-ark referenced this in commit a010bc2dbb on Jun 23, 2025
  30. willcl-ark referenced this in commit e27a94596f on Jun 24, 2025
  31. fanquake closed this on Jun 25, 2025

  32. fanquake referenced this in commit 7d5a6d1739 on Jun 25, 2025
  33. fanquake referenced this in commit e37a70bf71 on Jun 25, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-14 18:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me