Commit 471e3e70 authored by Adkins, Cameron's avatar Adkins, Cameron
Browse files

qt6: add windows deploy hook

parent d60627b1
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -185,6 +185,16 @@ let
          } ./hooks/wrap-qt-apps-hook.sh)
        { };

      deployQtWinPluginsHook = callPackage
        ({ qtbase }: makeSetupHook
          {
            name = "deploy-qt6-win-plugins-hook";
            substitutions = {
              qtPluginPath = "${qtbase + "/" + qtbase.qtPluginPrefix}";
            };
          } ./hooks/deploy-qt-win-plugins-hook.sh)
        { };

      qmake = callPackage
        ({ qtbase }: makeSetupHook
          {
+46 −0
Original line number Diff line number Diff line
if [[ -z "${__nix_deployQtWinPluginsHook-}" ]]; then
    __nix_deployQtWinPluginsHook=1 # Don't run this hook more than once.

    qtPluginPath="@qtPluginPath@"

    deployQt() {
        # Check if already deployed
        local targetDir=$(dirname "$1")

        echo "qtPluginPath: $qtPluginPath"

        for pluginDir in $qtPluginPath/*/; do
            local targetPluginDir="$targetDir/$(basename $pluginDir)"

            if ! [ -L "$targetPluginDir" ]; then
                echo "Linking Qt plugins at $targetPluginDir"
                ln -s $pluginDir $targetPluginDir
            fi
        done
    }

    deployQtWinPluginsHook() {
        # skip this hook when requested
        [ -z "${dontDeployQtWinPlugins-}" ] || return 0

        # guard against running multiple times (e.g. due to propagation)
        [ -z "$deployQtWinPluginsHookHasRun" ] || return 0
        deployQtWinPluginsHookHasRun=1

        local targetDirs=("$prefix/bin" "$prefix/sbin" "$prefix/libexec" "$prefix/Applications" "$prefix/"*.app)
        echo "deploying plugins for Qt applications in ${targetDirs[@]}"

        for targetDir in "${targetDirs[@]}"; do
            [ -d "$targetDir" ] || continue

            find "$targetDir" ! -type d -executable -print0 | while IFS= read -r -d '' file; do
                if [ -f "$file" ]; then
                    echo "deploying for $file"
                    deployQt "$file"
                fi
            done
        done
    }

    fixupOutputHooks+=(deployQtWinPluginsHook)
fi