@rhendric thanks for the explanation, I think I understand why you think the pattern I showed is not necessarily good. However I have another evidence that it might be needed even for qt6Packages:
Take the current branch master, and apply this commit:
commit fd0a2f2a0984b5a67c67fa8ec8c0093a6d239e39
Author: Doron Behar <doron.behar@gmail.com>
Date: Thu Jun 4 14:14:28 2026 +0300
musescore: use qt6Packages
As no kdePackages specific packages are needed
diff --git a/pkgs/by-name/mu/musescore/package.nix b/pkgs/by-name/mu/musescore/package.nix
index 0deadb2f1cfe..4fba53caaaa1 100644
--- a/pkgs/by-name/mu/musescore/package.nix
+++ b/pkgs/by-name/mu/musescore/package.nix
@@ -15,7 +15,7 @@
alsa-plugins,
flac,
freetype,
- kdePackages,
+ qt6Packages,
lame,
libjack2,
libogg,
@@ -64,7 +64,7 @@ let
]
)
) partiallyOverriddenScope;
- kdePackages' = overrideScopeFully kdePackages (
+ qt6Packages' = overrideScopeFully qt6Packages (
self: super: {
# Fix for: https://github.com/NixOS/nixpkgs/issues/526825
# reported upstream at: https://github.com/musescore/MuseScore/issues/33015
@@ -142,8 +142,8 @@ stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs = [
cmake
- kdePackages'.qttools
- kdePackages'.wrapQtAppsHook
+ qt6Packages'.qttools
+ qt6Packages'.wrapQtAppsHook
ninja
pkg-config
]
@@ -156,12 +156,12 @@ stdenv.mkDerivation (finalAttrs: {
buildInputs = [
flac
freetype
- kdePackages'.qt5compat
- kdePackages'.qtbase
- kdePackages'.qtdeclarative
- kdePackages'.qtnetworkauth
- kdePackages'.qtscxml
- kdePackages'.qtsvg
+ qt6Packages'.qt5compat
+ qt6Packages'.qtbase
+ qt6Packages'.qtdeclarative
+ qt6Packages'.qtnetworkauth
+ qt6Packages'.qtscxml
+ qt6Packages'.qtsvg
lame
libjack2
libogg
@@ -178,7 +178,7 @@ stdenv.mkDerivation (finalAttrs: {
]
++ lib.optionals stdenv.hostPlatform.isLinux [
alsa-lib
- kdePackages'.qtwayland
+ qt6Packages'.qtwayland
];
strictDeps = true;
And then note the musescore.drvPath is the same as before:
/nix/store/rz8hghkliz9v10c5ay4xm4nh4swvsgsr-musescore-4.7.2.drv
And if you’d apply:
diff --git i/pkgs/by-name/mu/musescore/package.nix w/pkgs/by-name/mu/musescore/package.nix
index 4fba53caaaa1..0e52f1aae89d 100644
--- i/pkgs/by-name/mu/musescore/package.nix
+++ w/pkgs/by-name/mu/musescore/package.nix
@@ -35,36 +35,7 @@
}:
let
- # TODO(@doronbehar): Contribute this one day to lib/? See:
- # https://discourse.nixos.org/t/rfc-nix-function-that-overrides-a-scope-with-automatic-inheritance-propagation/78025
- overrideScopeFully =
- s: scopeOverrideFunc:
- let
- partiallyOverriddenScope = s.overrideScope scopeOverrideFunc;
- directlyOverriddenAttrs = builtins.attrNames (scopeOverrideFunc partiallyOverriddenScope s);
- in
- builtins.mapAttrs (
- attrName: pkg:
- pkg.override (
- lib.pipe directlyOverriddenAttrs [
- (builtins.filter (
- oAttr:
- # Don't include in this filter the attribute `attrName` from the
- # full scope, if it is already part of the _directly_ overridden
- # attributes.
- !(builtins.elem attrName directlyOverriddenAttrs)
- && pkg ? override
- # Continue with the creation of the `.override` arguments only for
- # overridden attributes (`oAttr`) which are possible arguments to the
- # `.override` function of the `pkg` at hand.
- && pkg.override.__functionArgs ? ${oAttr}
- ))
- # Generate the `.override` argument using the attribute names `aNames`
- (aNames: lib.genAttrs aNames (oAttr: partiallyOverriddenScope.${oAttr}))
- ]
- )
- ) partiallyOverriddenScope;
- qt6Packages' = overrideScopeFully qt6Packages (
+ qt6Packages' = qt6Packages.overrideScope (
self: super: {
# Fix for: https://github.com/NixOS/nixpkgs/issues/526825
# reported upstream at: https://github.com/musescore/MuseScore/issues/33015
You’d get a different hash:
/nix/store/0ah934n1y6q4q10gnyibif4cy6wiyvqg-musescore-4.7.2.drv
Why is qt6Packages.overrideScope not overriding all packages that use qtdeclarative?
When in current branch master, I applied:
diff --git i/pkgs/by-name/mu/musescore/package.nix w/pkgs/by-name/mu/musescore/package.nix
index 0deadb2f1cfe..c742a757eb82 100644
--- i/pkgs/by-name/mu/musescore/package.nix
+++ w/pkgs/by-name/mu/musescore/package.nix
@@ -34,53 +34,6 @@
nixosTests,
}:
-let
- # TODO(@doronbehar): Contribute this one day to lib/? See:
- # https://discourse.nixos.org/t/rfc-nix-function-that-overrides-a-scope-with-automatic-inheritance-propagation/78025
- overrideScopeFully =
- s: scopeOverrideFunc:
- let
- partiallyOverriddenScope = s.overrideScope scopeOverrideFunc;
- directlyOverriddenAttrs = builtins.attrNames (scopeOverrideFunc partiallyOverriddenScope s);
- in
- builtins.mapAttrs (
- attrName: pkg:
- pkg.override (
- lib.pipe directlyOverriddenAttrs [
- (builtins.filter (
- oAttr:
- # Don't include in this filter the attribute `attrName` from the
- # full scope, if it is already part of the _directly_ overridden
- # attributes.
- !(builtins.elem attrName directlyOverriddenAttrs)
- && pkg ? override
- # Continue with the creation of the `.override` arguments only for
- # overridden attributes (`oAttr`) which are possible arguments to the
- # `.override` function of the `pkg` at hand.
- && pkg.override.__functionArgs ? ${oAttr}
- ))
- # Generate the `.override` argument using the attribute names `aNames`
- (aNames: lib.genAttrs aNames (oAttr: partiallyOverriddenScope.${oAttr}))
- ]
- )
- ) partiallyOverriddenScope;
- kdePackages' = overrideScopeFully kdePackages (
- self: super: {
- # Fix for: https://github.com/NixOS/nixpkgs/issues/526825
- # reported upstream at: https://github.com/musescore/MuseScore/issues/33015
- qtdeclarative = super.qtdeclarative.overrideAttrs (
- new: old: {
- patches = old.patches ++ [
- (fetchpatch {
- url = "https://github.com/qt/qtdeclarative/commit/9d4d376726a6ce15c429128dc65b927e411e40da.patch";
- hash = "sha256-XhfliF5wZuN4/E55f8hfipIRjxBe9V7vL1cgn5p4xqA=";
- })
- ];
- }
- );
- }
- );
-in
stdenv.mkDerivation (finalAttrs: {
pname = "musescore";
version = "4.7.2";
@@ -142,8 +95,8 @@ stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs = [
cmake
- kdePackages'.qttools
- kdePackages'.wrapQtAppsHook
+ kdePackages.qttools
+ kdePackages.wrapQtAppsHook
ninja
pkg-config
]
@@ -156,12 +109,12 @@ stdenv.mkDerivation (finalAttrs: {
buildInputs = [
flac
freetype
- kdePackages'.qt5compat
- kdePackages'.qtbase
- kdePackages'.qtdeclarative
- kdePackages'.qtnetworkauth
- kdePackages'.qtscxml
- kdePackages'.qtsvg
+ kdePackages.qt5compat
+ kdePackages.qtbase
+ kdePackages.qtdeclarative
+ kdePackages.qtnetworkauth
+ kdePackages.qtscxml
+ kdePackages.qtsvg
lame
libjack2
libogg
@@ -178,7 +131,7 @@ stdenv.mkDerivation (finalAttrs: {
]
++ lib.optionals stdenv.hostPlatform.isLinux [
alsa-lib
- kdePackages'.qtwayland
+ kdePackages.qtwayland
];
strictDeps = true;
diff --git i/pkgs/development/libraries/qt-6/modules/qtdeclarative/default.nix w/pkgs/development/libraries/qt-6/modules/qtdeclarative/default.nix
index 786229c5651b..26a55c54d455 100644
--- i/pkgs/development/libraries/qt-6/modules/qtdeclarative/default.nix
+++ w/pkgs/development/libraries/qt-6/modules/qtdeclarative/default.nix
@@ -43,6 +43,10 @@ qtModule {
hash = "sha256-ESy35OlmsvI4yFQ/rFT8oelOUBCwCmlcbQJvwcTrCig=";
revert = true;
})
+ (fetchpatch {
+ url = "https://github.com/qt/qtdeclarative/commit/9d4d376726a6ce15c429128dc65b927e411e40da.patch";
+ hash = "sha256-XhfliF5wZuN4/E55f8hfipIRjxBe9V7vL1cgn5p4xqA=";
+ })
];
cmakeFlags = [
And got the same derivation path:
/nix/store/rz8hghkliz9v10c5ay4xm4nh4swvsgsr-musescore-4.7.2.drv
However to be honest, before checking your claim, I did notice that my overrideScopeFully function indeed can forget to apply overrides in the following case: If A depends on B which depends on qtdeclarative, A’s .override call only gets direct scope members - it doesn’t see that B itself was transitively affected. This however doesn’t affect wrapQtAppsHook because it doesn’t really use qtwayland, although it is part of its override.__functionArgs.
The fix is to recursively look for packages that depend on the directly overridden qtdeclarative. I tried to write something with Claude, but I’m not sure it is good so I won’t post it.