From cd5e77db802275de6b21c6eccde59f1f4b88d4f4 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Sun, 31 May 2026 10:40:59 +0100 Subject: [PATCH] wrapQtAppsHook: support structuredAttrs With `__structuredAttrs = true`, `qtWrapperArgs` is provided as an array; without it, it is provided as a string. Use stdenv's `concatTo` helper to normalize `qtWrapperArgs` to a bash array, regardless of its representation. Adjust the hook's tests to cover both __structuredAttrs true and false. --- .../libraries/qt-5/hooks/wrap-qt-apps-hook.sh | 7 +++++-- .../libraries/qt-6/hooks/wrap-qt-apps-hook.sh | 7 +++++-- .../libraries/qt-6/tests/wrap-qt-apps-hook.nix | 16 ++++++++++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh b/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh index 6f7cdac0c941..0bbdeea1796a 100644 --- a/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh +++ b/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh @@ -3,8 +3,11 @@ __nix_wrapQtAppsHook=1 # wrap only once per output declare -a qtWrapperDoneForOuputs -# Inherit arguments given in mkDerivation -qtWrapperArgs=( ${qtWrapperArgs-} ) +# Normalize qtWrapperArgs to an array +declare -a _qtWrapperArgsTmp +concatTo _qtWrapperArgsTmp qtWrapperArgs +qtWrapperArgs=("${_qtWrapperArgsTmp[@]}") +unset _qtWrapperArgsTmp qtHostPathSeen=() diff --git a/pkgs/development/libraries/qt-6/hooks/wrap-qt-apps-hook.sh b/pkgs/development/libraries/qt-6/hooks/wrap-qt-apps-hook.sh index 18056b9ddf3b..248d00b3dda2 100644 --- a/pkgs/development/libraries/qt-6/hooks/wrap-qt-apps-hook.sh +++ b/pkgs/development/libraries/qt-6/hooks/wrap-qt-apps-hook.sh @@ -3,8 +3,11 @@ if [[ -z "${__nix_wrapQtAppsHook-}" ]]; then # wrap only once per output declare -a qtWrapperDoneForOuputs - # Inherit arguments given in mkDerivation - qtWrapperArgs=(${qtWrapperArgs-}) + # Normalize qtWrapperArgs to an array + declare -a _qtWrapperArgsTmp + concatTo _qtWrapperArgsTmp qtWrapperArgs + qtWrapperArgs=("${_qtWrapperArgsTmp[@]}") + unset _qtWrapperArgsTmp qtHostPathSeen=() diff --git a/pkgs/development/libraries/qt-6/tests/wrap-qt-apps-hook.nix b/pkgs/development/libraries/qt-6/tests/wrap-qt-apps-hook.nix index e43ff3b6e3ac..e9010031e879 100644 --- a/pkgs/development/libraries/qt-6/tests/wrap-qt-apps-hook.nix +++ b/pkgs/development/libraries/qt-6/tests/wrap-qt-apps-hook.nix @@ -68,6 +68,7 @@ let inherit qtWrapperArgs; buildInputs = [ qtbase ]; nativeBuildInputs = [ wrapQtAppsHook ]; + __structuredAttrs = true; } '' ${lib.toShellVars { @@ -126,7 +127,7 @@ let ''; in -{ +lib.fix (self: { simple = checkWrapperArgsArray { name = "simple"; @@ -136,6 +137,11 @@ in ]; }; + simple-no-structuredAttrs = self.simple.overrideAttrs (prevAttrs: { + name = prevAttrs.name + "-no-structuredAttrs"; + __structuredAttrs = false; + }); + # Integration test: assert program is wrapped with the expected environment runtime = runCommandLocal "simple-wrapper-runtime" @@ -148,6 +154,7 @@ in buildInputs = [ qtbase ]; nativeBuildInputs = [ wrapQtAppsHook ]; + __structuredAttrs = true; } '' # Install the test program @@ -159,4 +166,9 @@ in "$out/bin/test" ''; -} + runtime-no-structuredAttrs = self.runtime.overrideAttrs (prevAttrs: { + name = prevAttrs.name + "-no-structuredAttrs"; + __structuredAttrs = false; + }); + +})