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.
This commit is contained in:
Matt Sturgeon
2026-06-04 01:43:31 +01:00
parent 75a1c47a4e
commit cd5e77db80
3 changed files with 24 additions and 6 deletions
@@ -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=()
@@ -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=()
@@ -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;
});
})