Nixpkgs commit that mysteriously broke my cmake environment

I have a custom build package that works until recently. Link to the said custom pkg

I checked and it was built just fine in 3212a37, and I have been pining nixpkgs to that rev since forever. I tried switching to the commit right after it, which is cc8e3c2 and it would not build.

What strange is that the commit cc8e3c2 doesn’t seem to have anything to do with cmake

Apparently CMAKE_PREFIX_PATH was not set in build command, this is the build log:

Running phase: qtPreHook
@nix { "action": "setPhase", "phase": "qtPreHook" }
Running phase: unpackPhase
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking source archive /nix/store/jwkkw9cvbvxf98ikhphgjgb551nlfpq6-source
source root is source
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: configurePhase
@nix { "action": "setPhase", "phase": "configurePhase" }
fixing cmake files...
cmake flags: -DCMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=OFF 
-DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF 
-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON 
-DCMAKE_BUILD_TYPE=Release 
-DBUILD_TESTING=OFF 
-DCMAKE_INSTALL_LOCALEDIR=/nix/store/g6sxybp240fa72387faqjjn46xsxsjhn-caesium-image-compressor-2.7.1/share/locale 
-DCMAKE_INSTALL_LIBEXECDIR=/nix/store/g6sxybp240fa72387faqjjn46xsxsjhn-caesium-image-compressor-2.7.1/libexec 
-DCMAKE_INSTALL_LIBDIR=/nix/store/g6sxybp240fa72387faqjjn46xsxsjhn-caesium-image-compressor-2.7.1/lib 
-DCMAKE_INSTALL_DOCDIR=/nix/store/g6sxybp240fa72387faqjjn46xsxsjhn-caesium-image-compressor-2.7.1/share/doc/caesium-image-compressor 
-DCMAKE_INSTALL_INFODIR=/nix/store/g6sxybp240fa72387faqjjn46xsxsjhn-caesium-image-compressor-2.7.1/share/info 
-DCMAKE_INSTALL_MANDIR=/nix/store/g6sxybp240fa72387faqjjn46xsxsjhn-caesium-image-compressor-2.7.1/share/man 
-DCMAKE_INSTALL_OLDINCLUDEDIR=/nix/store/g6sxybp240fa72387faqjjn46xsxsjhn-caesium-image-compressor-2.7.1/include 
-DCMAKE_INSTALL_INCLUDEDIR=/nix/store/g6sxybp240fa72387faqjjn46xsxsjhn-caesium-image-compressor-2.7.1/include 
-DCMAKE_INSTALL_SBINDIR=/nix/store/g6sxybp240fa72387faqjjn46xsxsjhn-caesium-image-compressor-2.7.1/sbin 
-DCMAKE_INSTALL_BINDIR=/nix/store/g6sxybp240fa72387faqjjn46xsxsjhn-caesium-image-compressor-2.7.1/bin 
-DCMAKE_INSTALL_NAME_DIR=/nix/store/g6sxybp240fa72387faqjjn46xsxsjhn-caesium-image-compressor-2.7.1/lib 
-DCMAKE_POLICY_DEFAULT_CMP0025=NEW 
-DCMAKE_OSX_SYSROOT= -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_STRIP=/nix/store/zznja5f8v3jafffyah1rk46vpfcn38dv-gcc-wrapper-13.3.0/bin/strip 
-DCMAKE_RANLIB=/nix/store/zznja5f8v3jafffyah1rk46vpfcn38dv-gcc-wrapper-13.3.0/bin/ranlib 
-DCMAKE_AR=/nix/store/zznja5f8v3jafffyah1rk46vpfcn38dv-gcc-wrapper-13.3.0/bin/ar 
-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_INSTALL_PREFIX=/nix/store/g6sxybp240fa72387faqjjn46xsxsjhn-caesium-image-compressor-2.7.1
-- The CXX compiler identification is GNU 13.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /nix/store/zznja5f8v3jafffyah1rk46vpfcn38dv-gcc-wrapper-13.3.0/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:52 (message):
  CMAKE_PREFIX_PATH is not defined.  Cannot find Qt dir.


-- Configuring incomplete, errors occurred!

I don’t know where you got the impression from that these two commits follow each other but neither is the other’s parent. There’s 11481 commits between them in fact.

Could you do a first-parent bisect between the two?

Hello, I took a break and completely forgot about this post. I’m so sorry

It turns out that when i do git bisect, i got the specific commit

they change it from

addCMakeParams() {
    addToSearchPath CMAKE_PREFIX_PATH $1
}

to:

addCMakeParams() {
    addToSearchPath NIXPKGS_CMAKE_PREFIX_PATH $1
}

I’m still not sure how do i fix this since in the original package’s CMakeList.txt contains this:

if (NOT (DEFINED ENV{CMAKE_PREFIX_PATH} OR DEFINED CMAKE_PREFIX_PATH))
    message(FATAL_ERROR "CMAKE_PREFIX_PATH is not defined. Cannot find Qt dir.")
endif ()

# And this:

find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets Core Gui Concurrent Svg Network Sql LinguistTools REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets Core Gui Concurrent Svg Network Sql LinguistTools REQUIRED)

and acording to what i know, CMAKE_PREFIX_PATH flag is required to use find_package in cmake

The move to NIXPKGS_CMAKE_PREFIX_PATH also caused us a lot of problems in nix-ros-overlay. See: Since b6676bf cmake_modules cannot be found · Issue #491 · lopsided98/nix-ros-overlay · GitHub basically the solution ended up being to patch some .cmake files in catkin.

1 Like

Thank you so much for the solution. Though I have a dumb question. How do i make a patch file?
do i just copy the .cmake file to another location, fix it and diff -u ./a/CMakeList.txt ./b/CMakeList.txt > cmake_patch.patch?

I have a feeling like it is not the case at all. Could you please teach me how do i make patch file properly?

Looking at the previously linked CMakeList.txt it seems there is just a check to see if CMAKE_PREFIX_PATH exists but it doesn’t actually do anything with it, as below it seems to just use normal find_package. if this is the case, there is no patch required and in your derivation you can probably just set env.CMAKE_PREFIX_PATH = ""; to satisfy the check and things should build.

FWIW: the change which removed CMAKE_PREFIX_PATH from the cmake setup hook is this one: cmake: fix strictDeps by paparodeo · Pull Request #318226 · NixOS/nixpkgs · GitHub