Based on How can I create a development shell for qt 5.5 with debug symbols in the qt libraries, and looking at qtbase.nix, I tried this in default.nix:
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "myapp";
buildInputs = [
(qt5.qtbase.override { debug = true; })
qt5.qtdeclarative
qt5.qtgraphicaleffects
qt5.qtimageformats
qt5.qtquickcontrols2
qt5.qttools
...unrelated deps...
];
}
This seemed to build Qt successfully, but then when invoking nix-shell, I get the error:
Error: detected mismatched Qt dependencies:
/nix/store/2w9sd3z24hhxvllk47xwflwcsh318k1q-qtbase-5.15.3-dev
/nix/store/74ly900da8fi9b5vvmyqzi4yqa84p0sz-qtbase-5.15.3-dev
The very few hits that google finds for this error message do not seem to be relevant to the situation.
After looking at strace output and drv files, I intuited that maybe qtdeclarative is still using the non-overridden version of qtbase, so then I tried:
with import <nixpkgs> {};
let myqtbase = qt5.qtbase.override { debug = true; }; in
let myqtdecl = qt5.qtdeclarative.override { qtbase = myqtbase; }; in
stdenv.mkDerivation {
name = "myapp";
buildInputs = [
myqtbase
myqtdecl
(qt5.qtgraphicaleffects.override { qtdeclarative = myqtdecl; })
(qt5.qtimageformats.override { qtbase = myqtbase; })
(qt5.qtquickcontrols2.override { qtdeclarative = myqtdecl; })
(qt5.qttools.override { qtbase = myqtbase; qtdeclarative = myqtdecl; })
...unrelated deps...
];
}
This time, it fails earlier with basically the same issue:
these 5 derivations will be built:
/nix/store/khxivycbzgvjcxypa1im98grvpnjp2rd-qtdeclarative-5.15.3.drv
/nix/store/bax6i6afc6bgc6qjgbrps8l5q3r3fbis-qttools-5.15.3.drv
/nix/store/hhcnis5nh4raixqajj67zvak7xx44q3y-qtimageformats-5.15.3.drv
/nix/store/jl43kcgfm9svrnddja9bi0kwhqxrcs27-qtgraphicaleffects-5.15.3.drv
/nix/store/wjhaakqxzdk5x5j315mx16rdqagrnavl-qtquickcontrols2-5.15.3.drv
building '/nix/store/khxivycbzgvjcxypa1im98grvpnjp2rd-qtdeclarative-5.15.3.drv'...
Error: detected mismatched Qt dependencies:
/nix/store/74ly900da8fi9b5vvmyqzi4yqa84p0sz-qtbase-5.15.3-dev
/nix/store/2w9sd3z24hhxvllk47xwflwcsh318k1q-qtbase-5.15.3-dev
error: builder for '/nix/store/khxivycbzgvjcxypa1im98grvpnjp2rd-qtdeclarative-5.15.3.drv' failed with exit code 1;
last 3 log lines:
> Error: detected mismatched Qt dependencies:
> /nix/store/74ly900da8fi9b5vvmyqzi4yqa84p0sz-qtbase-5.15.3-dev
> /nix/store/2w9sd3z24hhxvllk47xwflwcsh318k1q-qtbase-5.15.3-dev
For full logs, run 'nix log /nix/store/khxivycbzgvjcxypa1im98grvpnjp2rd-qtdeclarative-5.15.3.drv'.
error: build of '/nix/store/bax6i6afc6bgc6qjgbrps8l5q3r3fbis-qttools-5.15.3.drv', '/nix/store/hhcnis5nh4raixqajj67zvak7xx44q3y-qtimageformats-5.15.3.drv', '/nix/store/jl43kcgfm9svrnddja9bi0kwhqxrcs27-qtgraphicaleffects-5.15.3.drv', '/nix/store/khxivycbzgvjcxypa1im98grvpnjp2rd-qtdeclarative-5.15.3.drv', '/nix/store/wjhaakqxzdk5x5j315mx16rdqagrnavl-qtquickcontrols2-5.15.3.drv' failed
At this point, I don't have a single clue what or where is trying to pull in different versions of qtbase (both -dev!) or why and I'm out of ideas.
I also looked at https://nixos.org/manual/nixpkgs/stable/#sec-pkg-override which is linked from the previous Q&A, but my familiarity with Nix is insufficiently deep to truly comprehend what's written there.
Halp?
Well, in your
default.nixyou've overriden the wrong attribute. The correct way is:Result:
Unfortunately (or fortunately)
nixis a full-blown programming language with unbounded recursion and other high-level functional utility. Which means great flexibility, which is great. But sometimes, one just have to look into the source code in thenixpkgs. The correct parameters are defined in the qt 5's default.nix and from there it's pretty easy to figure out why overriding just the submodule fails.