Skip to content

Commit

Permalink
Merge pull request #265524 from Artturin/usemakescopew
Browse files Browse the repository at this point in the history
  • Loading branch information
Artturin authored Nov 24, 2023
2 parents 102c2a8 + 410cd59 commit 81ca4c3
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 25 deletions.
42 changes: 27 additions & 15 deletions pkgs/development/libraries/qt-6/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{ newScope
, lib
, stdenv
, generateSplicesForMkScope
, makeScopeWithSplicing'
, fetchurl
, fetchpatch
, fetchpatch2
Expand All @@ -12,6 +14,7 @@
, overrideSDK
, buildPackages
, python3
, config

# options
, developerBuild ? false
Expand All @@ -24,10 +27,11 @@ let
mirror = "mirror://qt";
};

addPackages = self: with self;
addPackages = self:
let
callPackage = self.newScope ({
inherit qtModule srcs python3;
inherit (self) qtModule;
inherit srcs python3;
stdenv = if stdenv.isDarwin then darwin.apple_sdk_11_0.stdenv else stdenv;
});
in
Expand Down Expand Up @@ -58,7 +62,9 @@ let
];
};
env = callPackage ./qt-env.nix { };
full = env "qt-full-${qtbase.version}" ([
full = callPackage ({ env, qtbase }: env "qt-full-${qtbase.version}"
# `with self` is ok to use here because having these spliced is unnecessary
( with self;[
qt3d
qt5compat
qtcharts
Expand Down Expand Up @@ -96,7 +102,7 @@ let
qtwebengine
qtwebsockets
qtwebview
] ++ lib.optionals (!stdenv.isDarwin) [ qtwayland libglvnd ]);
] ++ lib.optionals (!stdenv.isDarwin) [ qtwayland libglvnd ])) { };

qt3d = callPackage ./modules/qt3d.nix { };
qt5compat = callPackage ./modules/qt5compat.nix { };
Expand Down Expand Up @@ -149,11 +155,11 @@ let
GameController ImageCaptureCore LocalAuthentication
MediaAccessibility MediaPlayer MetalKit Network OpenDirectory Quartz
ReplayKit SecurityInterface Vision;
qtModule = qtModule.override {
qtModule = callPackage ({ qtModule }: qtModule.override {
stdenv = if stdenv.isDarwin
then overrideSDK stdenv { darwinMinVersion = "10.13"; darwinSdkVersion = "11.0"; }
else stdenv;
};
}) { };
xcbuild = buildPackages.xcbuild.override {
productBuildVer = "20A2408";
};
Expand All @@ -163,26 +169,32 @@ let
inherit (darwin.apple_sdk_11_0.frameworks) WebKit;
};

wrapQtAppsHook = makeSetupHook
wrapQtAppsHook = callPackage ({ makeBinaryWrapper }: makeSetupHook
{
name = "wrap-qt6-apps-hook";
propagatedBuildInputs = [ buildPackages.makeBinaryWrapper ];
} ./hooks/wrap-qt-apps-hook.sh;
propagatedBuildInputs = [ makeBinaryWrapper ];
} ./hooks/wrap-qt-apps-hook.sh) { };

qmake = makeSetupHook
qmake = callPackage ({ qtbase }: makeSetupHook
{
name = "qmake6-hook";
propagatedBuildInputs = [ self.qtbase.dev ];
propagatedBuildInputs = [ qtbase.dev ];
substitutions = {
inherit debug;
fix_qmake_libtool = ./hooks/fix-qmake-libtool.sh;
};
} ./hooks/qmake-hook.sh;
} ./hooks/qmake-hook.sh) { };
} // lib.optionalAttrs config.allowAliases {
# Convert to a throw on 03-01-2023 and backport the change.
# Warnings show up in various cli tool outputs, throws do not.
# Remove completely before 24.05
overrideScope' = lib.warnIf (lib.isInOldestRelease 2311) "qt6 now uses makeScopeWithSplicing which does not have \"overrideScope'\", use \"overrideScope\"." self.overrideScope;
};

# TODO(@Artturin): convert to makeScopeWithSplicing'
# simple example of how to do that in 5568a4d25ca406809530420996d57e0876ca1a01
baseScope = lib.makeScope newScope addPackages;
baseScope = makeScopeWithSplicing' {
otherSplices = generateSplicesForMkScope "qt6";
f = addPackages;
};

bootstrapScope = baseScope.overrideScope(final: prev: {
qtbase = prev.qtbase.override { qttranslations = null; };
Expand Down
2 changes: 1 addition & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24665,7 +24665,7 @@ with pkgs;
qt6 = recurseIntoAttrs (callPackage ../development/libraries/qt-6 { });

qt6Packages = recurseIntoAttrs (import ./qt6-packages.nix {
inherit lib pkgs qt6;
inherit lib __splicedPackages makeScopeWithSplicing' generateSplicesForMkScope pkgsBuildHost;
stdenv = if stdenv.isDarwin then darwin.apple_sdk_11_0.stdenv else stdenv;
});

Expand Down
5 changes: 3 additions & 2 deletions pkgs/top-level/qt5-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,9 @@ in (noExtraAttrs (kdeFrameworks // plasmaMobileGear // plasma5 // plasma5.thirdP

yuview = callPackage ../applications/video/yuview { };
}) // lib.optionalAttrs pkgs.config.allowAliases {
# remove after 23.11 branch-off and backport removal to 23.11
# 23.11 will have a warning for this in `makeScope` itself
# Convert to a throw on 01-01-2023.
# Warnings show up in various cli tool outputs, throws do not.
# Remove completely before 24.05
overrideScope' = lib.warn "libsForQt5 now uses makeScopeWithSplicing which does not have \"overrideScope'\", use \"overrideScope\"." self.overrideScope;
}));
}
31 changes: 24 additions & 7 deletions pkgs/top-level/qt6-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,27 @@
# this file.

{ lib
, pkgs
, qt6
, __splicedPackages
, makeScopeWithSplicing'
, generateSplicesForMkScope
, stdenv
, pkgsBuildHost
}:

(lib.makeScope pkgs.newScope ( self:

let
callPackage = self.callPackage;
pkgs = __splicedPackages;
# qt6 set should not be pre-spliced to prevent spliced packages being a part of an unspliced set
# 'pkgsCross.aarch64-multiplatform.pkgsBuildTarget.targetPackages.qt6Packages.qtbase' should not have a `__spliced` but if qt6 is pre-spliced then it will have one.
# pkgsBuildHost == pkgs
qt6 = pkgsBuildHost.qt6;
in
(qt6 // {

makeScopeWithSplicing' {
otherSplices = generateSplicesForMkScope "qt6Packages";
f = (self: let
inherit (self) callPackage;
noExtraAttrs = set: lib.attrsets.removeAttrs set [ "extend" "override" "overrideScope" "overrideScope'" "overrideDerivation" ];
in (noExtraAttrs qt6) // {
inherit stdenv;

# LIBRARIES
Expand Down Expand Up @@ -45,4 +55,11 @@ in
qt6Support = true;
suffix = "qt6";
};
})))

} // lib.optionalAttrs pkgs.config.allowAliases {
# Convert to a throw on 01-01-2023.
# Warnings show up in various cli tool outputs, throws do not.
# Remove completely before 24.05
overrideScope' = lib.warn "qt6Packages now uses makeScopeWithSplicing which does not have \"overrideScope'\", use \"overrideScope\"." self.overrideScope;
});
}

0 comments on commit 81ca4c3

Please sign in to comment.