push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
# Fix libtool libraries generated by qmake.
# qmake started inserting filenames of shared objects instead of the appropriate
# linker flags. fixQmakeLibtool searches for broken libtool libraries and
# replaces the filenames with the linker flags that should have been there.
fixQmakeLibtool() {
if [ -d "$1" ]; then
find "$1" -name '*.la' | while read la; do
set +e
framework_libs=$(grep '^dependency_libs' "$la" | grep -Eo -- '-framework +\w+' | tr '\n' ' ')
set -e
sed -i "$la" \
-e '/^dependency_libs/ s,\(/[^ ]\+\)/lib\([^/ ]\+\)\.so,-L\1 -l\2,g' \
-e '/^dependency_libs/ s,-framework \+\w\+,,g'
if [ ! -z "$framework_libs" ]; then
if grep '^inherited_linker_flags=' $la >/dev/null; then
sed -i "$la" -e "s/^\(inherited_linker_flags='[^']*\)/\1 $framework_libs/"
else
echo "inherited_linker_flags='$framework_libs'" >>"$la"
fi
fi
done
fi
}
fixupOutputHooks+=('fixQmakeLibtool $prefix')

View File

@@ -0,0 +1,63 @@
# fixQtBuiltinPaths
#
# Usage: fixQtBuiltinPaths _dir_ _pattern_
#
# Fix Qt builtin paths in files matching _pattern_ under _dir_.
#
fixQtBuiltinPaths() {
local dir="$1"
local pattern="$2"
local lib="${!outputLib}"
if [ -d "$dir" ]; then
find "$dir" -name "$pattern" | while read pr_; do
if grep -q '\$\$\[QT_' "${pr_:?}"; then
echo "fixQtBuiltinPaths: Fixing Qt builtin paths in \`${pr_:?}'..."
sed -i "${pr_:?}" \
-e "s|\\\$\\\$\\[QT_HOST_BINS[^]]*\\]|$lib/bin|g" \
-e "s|\\\$\\\$\\[QT_HOST_LIBEXECS[^]]*\\]|$lib/libexec|g" \
-e "s|\\\$\\\$\\[QT_HOST_DATA[^]]*\\]/mkspecs|$lib/mkspecs|g" \
-e "s|\\\$\\\$\\[QT_HOST_PREFIX[^]]*\\]|$lib|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_ARCHDATA[^]]*\\]|$lib|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_BINS[^]]*\\]|$lib/bin|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_CONFIGURATION[^]]*\\]|$lib|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_DATA[^]]*\\]|$lib|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_DOCS[^]]*\\]|$lib/share/doc|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_EXAMPLES[^]]*\\]|$lib/examples|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_HEADERS[^]]*\\]|$lib/include|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_LIBS[^]]*\\]|$lib/lib|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_LIBEXECS[^]]*\\]|$lib/libexec|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_PLUGINS[^]]*\\]|$lib/$qtPluginPrefix|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_PREFIX[^]]*\\]|$lib|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_TESTS[^]]*\\]|$lib/tests|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_TRANSLATIONS[^]]*\\]|$lib/translations|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_QML[^]]*\\]|$lib/$qtQmlPrefix|g"
fi
done
elif [ -e "$dir" ]; then
if grep -q '\$\$\[QT_' "${dir:?}"; then
echo "fixQtBuiltinPaths: Fixing Qt builtin paths in \`${dir:?}'..."
sed -i "${dir:?}" \
-e "s|\\\$\\\$\\[QT_HOST_BINS[^]]*\\]|$lib/bin|g" \
-e "s|\\\$\\\$\\[QT_HOST_LIBEXECS[^]]*\\]|$lib/libexec|g" \
-e "s|\\\$\\\$\\[QT_HOST_DATA[^]]*\\]/mkspecs|$lib/mkspecs|g" \
-e "s|\\\$\\\$\\[QT_HOST_PREFIX[^]]*\\]|$lib|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_ARCHDATA[^]]*\\]|$lib|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_BINS[^]]*\\]|$lib/bin|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_CONFIGURATION[^]]*\\]|$lib|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_DATA[^]]*\\]|$lib|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_DOCS[^]]*\\]|$lib/share/doc|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_EXAMPLES[^]]*\\]|$lib/examples|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_HEADERS[^]]*\\]|$lib/include|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_LIBS[^]]*\\]|$lib/lib|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_LIBEXECS[^]]*\\]|$lib/libexec|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_PLUGINS[^]]*\\]|$lib/$qtPluginPrefix|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_PREFIX[^]]*\\]|$lib|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_TESTS[^]]*\\]|$lib/tests|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_TRANSLATIONS[^]]*\\]|$lib/translations|g" \
-e "s|\\\$\\\$\\[QT_INSTALL_QML[^]]*\\]|$lib/$qtQmlPrefix|g"
fi
else
echo "fixQtBuiltinPaths: Warning: \`$dir' does not exist"
fi
}

View File

@@ -0,0 +1,27 @@
# fixQtModulePaths
#
# Usage: fixQtModulePaths _dir_
#
# Find Qt module definitions in directory _dir_ and patch the module paths.
#
fixQtModulePaths() {
local dir="$1"
local lib="${!outputLib}"
if [ -d "$dir" ]; then
find "$dir" -name 'qt_*.pri' | while read pr; do
if grep -q '\$\$QT_MODULE_' "${pr:?}"; then
echo "fixQtModulePaths: Fixing module paths in \`${pr:?}'..."
sed -i "${pr:?}" \
-e "s|\\\$\\\$QT_MODULE_LIB_BASE|$lib/lib|g" \
-e "s|\\\$\\\$QT_MODULE_HOST_LIB_BASE|$lib/lib|g" \
-e "s|\\\$\\\$QT_MODULE_INCLUDE_BASE|$lib/include|g" \
-e "s|\\\$\\\$QT_MODULE_BIN_BASE|$lib/bin|g"
fi
done
elif [ -e "$dir" ]; then
echo "fixQtModulePaths: Warning: \`$dir' is not a directory"
else
echo "fixQtModulePaths: Warning: \`$dir' does not exist"
fi
}

View File

@@ -0,0 +1,43 @@
. @fix_qmake_libtool@
qmakePrePhase() {
# These flags must be added _before_ the flags specified in the derivation.
# TODO: these flags also need a patch which isn't applied
# can we either remove these flags or update the qt5 patch?
# "NIX_OUTPUT_DOC=${!outputDev}/${qtDocPrefix:?}" \
prependToVar qmakeFlags \
"PREFIX=$out" \
"NIX_OUTPUT_OUT=$out" \
"NIX_OUTPUT_DEV=${!outputDev}" \
"NIX_OUTPUT_BIN=${!outputBin}" \
"NIX_OUTPUT_QML=${!outputBin}/${qtQmlPrefix:?}" \
"NIX_OUTPUT_PLUGIN=${!outputBin}/${qtPluginPrefix:?}"
}
appendToVar prePhases qmakePrePhase
qmakeConfigurePhase() {
runHook preConfigure
local flagsArray=()
concatTo flagsArray qmakeFlags
echo "QMAKEPATH=$QMAKEPATH"
echo qmake "${flagsArray[@]}"
qmake "${flagsArray[@]}"
if ! [[ -v enableParallelBuilding ]]; then
enableParallelBuilding=1
echo "qmake: enabled parallel building"
fi
if ! [[ -v enableParallelInstalling ]]; then
enableParallelInstalling=1
echo "qmake: enabled parallel installing"
fi
runHook postConfigure
}
if [ -z "${dontUseQmakeConfigure-}" -a -z "${configurePhase-}" ]; then
configurePhase=qmakeConfigurePhase
fi

View File

@@ -0,0 +1,96 @@
if [[ -n "${__nix_qtbase-}" ]]; then
# Throw an error if a different version of Qt was already set up.
if [[ "$__nix_qtbase" != "@out@" ]]; then
echo >&2 "Error: detected mismatched Qt dependencies:"
echo >&2 " @out@"
echo >&2 " $__nix_qtbase"
exit 1
fi
else # Only set up Qt once.
__nix_qtbase="@out@"
qtPluginPrefix=@qtPluginPrefix@
qtQmlPrefix=@qtQmlPrefix@
. @fix_qt_builtin_paths@
. @fix_qt_module_paths@
# Build tools are often confused if QMAKE is unset.
export QMAKE=@out@/bin/qmake
export QMAKEPATH=
export QMAKEMODULES=
declare -Ag qmakePathSeen=()
qmakePathHook() {
# Skip this path if we have seen it before.
# MUST use 'if' because 'qmakePathSeen[$]' may be unset.
if [ -n "${qmakePathSeen[$1]-}" ]; then return; fi
qmakePathSeen[$1]=1
if [ -d "$1/mkspecs" ]; then
QMAKEMODULES="${QMAKEMODULES}${QMAKEMODULES:+:}/mkspecs"
QMAKEPATH="${QMAKEPATH}${QMAKEPATH:+:}$1"
fi
}
envBuildHostHooks+=(qmakePathHook)
declare -g qttoolsPathSeen=
qtToolsHook() {
if [ -f "$1/libexec/qhelpgenerator" ]; then
if [[ -n "${qtToolsPathSeen:-}" && "${qttoolsPathSeen:-}" != "$1" ]]; then
echo >&2 "Error: detected mismatched Qt dependencies:"
echo >&2 " $1"
echo >&2 " $qttoolsPathSeen"
exit 1
fi
qttoolsPathSeen=$1
appendToVar cmakeFlags "-DQT_OPTIONAL_TOOLS_PATH=$1"
fi
}
addEnvHooks "$hostOffset" qtToolsHook
postPatchMkspecs() {
# Prevent this hook from running multiple times
dontPatchMkspecs=1
local lib="${!outputLib}"
local dev="${!outputDev}"
moveToOutput "mkspecs/modules" "$dev"
if [ -d "$dev/mkspecs/modules" ]; then
fixQtModulePaths "$dev/mkspecs/modules"
fi
if [ -d "$lib/mkspecs" ]; then
fixQtBuiltinPaths "$lib/mkspecs" '*.pr?'
fi
if [ -d "$lib/lib" ]; then
fixQtBuiltinPaths "$lib/lib" '*.pr?'
fi
}
if [ -z "${dontPatchMkspecs-}" ]; then
appendToVar postPhases postPatchMkspecs
fi
qtPreHook() {
# Check that wrapQtAppsHook/wrapQtAppsNoGuiHook is used, or it is explicitly disabled.
if [[ -z "$__nix_wrapQtAppsHook" && -z "$dontWrapQtApps" ]]; then
echo >&2 "Error: this derivation depends on qtbase, but no wrapping behavior was specified."
echo >&2 " - If this is a graphical application, add wrapQtAppsHook to nativeBuildInputs"
echo >&2 " - If this is a CLI application, add wrapQtAppsNoGuiHook to nativeBuildInputs"
echo >&2 " - If this is a library or you need custom wrapping logic, set dontWrapQtApps = true"
exit 1
fi
}
appendToVar prePhases qtPreHook
addQtModulePrefix() {
addToSearchPath QT_ADDITIONAL_PACKAGES_PREFIX_PATH $1
}
addEnvHooks "$hostOffset" addQtModulePrefix
fi

View File

@@ -0,0 +1,102 @@
if [[ -z "${__nix_wrapQtAppsHook-}" ]]; then
__nix_wrapQtAppsHook=1 # Don't run this hook more than once.
# Inherit arguments given in mkDerivation
qtWrapperArgs=(${qtWrapperArgs-})
qtHostPathSeen=()
qtUnseenHostPath() {
for pkg in "${qtHostPathSeen[@]}"; do
if [ "${pkg:?}" == "$1" ]; then
return 1
fi
done
qtHostPathSeen+=("$1")
return 0
}
qtHostPathHook() {
qtUnseenHostPath "$1" || return 0
if ! [ -v qtPluginPrefix ]; then
echo "wrapQtAppsHook qtHostPathHook: qtPluginPrefix is unset. hint: add qt6.qtbase to buildInputs"
fi
local pluginDir="$1/${qtPluginPrefix:?}"
if [ -d "$pluginDir" ]; then
qtWrapperArgs+=(--prefix QT_PLUGIN_PATH : "$pluginDir")
fi
local qmlDir="$1/${qtQmlPrefix:?}"
if [ -d "$qmlDir" ]; then
qtWrapperArgs+=(--prefix NIXPKGS_QT6_QML_IMPORT_PATH : "$qmlDir")
fi
}
addEnvHooks "$targetOffset" qtHostPathHook
makeQtWrapper() {
local original="$1"
local wrapper="$2"
shift 2
makeWrapper "$original" "$wrapper" "${qtWrapperArgs[@]}" "$@"
}
wrapQtApp() {
local program="$1"
shift 1
wrapProgram "$program" "${qtWrapperArgs[@]}" "$@"
}
qtOwnPathsHook() {
local xdgDataDir="${!outputBin}/share"
if [ -d "$xdgDataDir" ]; then
qtWrapperArgs+=(--prefix XDG_DATA_DIRS : "$xdgDataDir")
fi
local xdgConfigDir="${!outputBin}/etc/xdg"
if [ -d "$xdgConfigDir" ]; then
qtWrapperArgs+=(--prefix XDG_CONFIG_DIRS : "$xdgConfigDir")
fi
qtHostPathHook "${!outputBin}"
}
appendToVar preFixupPhases qtOwnPathsHook
# Note: $qtWrapperArgs still gets defined even if ${dontWrapQtApps-} is set.
wrapQtAppsHook() {
# skip this hook when requested
[ -z "${dontWrapQtApps-}" ] || return 0
# guard against running multiple times (e.g. due to propagation)
[ -z "$wrapQtAppsHookHasRun" ] || return 0
wrapQtAppsHookHasRun=1
local targetDirs=("$prefix/bin" "$prefix/sbin" "$prefix/libexec" "$prefix/Applications" "$prefix/"*.app)
echo "wrapping 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
# Skip the file if it is not a binary (ELF or Mach-O)
isELF "$file" || isMachO "$file" || continue
if [ -h "$file" ]; then
target="$(readlink -e "$file")"
echo "wrapping $file -> $target"
rm "$file"
makeQtWrapper "$target" "$file"
elif [ -f "$file" ]; then
echo "wrapping $file"
wrapQtApp "$file"
fi
done
done
}
fixupOutputHooks+=(wrapQtAppsHook)
fi