Skip to content

wrapGAppsHook: prepare for structuredAttrs - #511330

Merged
SFrijters merged 1 commit into
NixOS:stagingfrom
SFrijters:wrap-gapps-hook-staging
May 24, 2026
Merged

SFrijters merged 1 commit into
NixOS:stagingfrom
SFrijters:wrap-gapps-hook-staging

Conversation

@SFrijters

@SFrijters SFrijters commented Apr 19, 2026 •

Copy link
Copy Markdown
Member

This hook is called in the fixupPhase via

local output
for output in $(getAllOutputNames); do
  prefix="${!output}" runHook fixupOutput
done

Without __structuredAttrs, getAllOutputNames returns the output array, in order. However, with __structuredAttrs, it returns the keys of the output associative array, which are no longer necessarily ordered in the same way.

In the case of some packages (e.g. mate-panel-with-applets) this means that instead of [ "out" "man" ], we process [ "man" "out" ]. Running the hook for "man" then sets wrapGAppsHookHasRun and no wrapping is done for "out", which is what was really needed.

Instead, keep track of whether the hook has run on a per-output basis. That way, the order does not matter and any executables that are spread around multiple outputs are wrapped.

I tried to do this using an associative array to keep track of which outputs we've already seen, but I couldn't get the syntax to work for some reason (maybe due to lack of sleep :)) - if the general approach makes sense I can take another stab at that.

This should allow #511162 to be reverted.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

@SFrijters
SFrijters force-pushed the wrap-gapps-hook-staging branch from fb19350 to 1a75510 Compare April 19, 2026 09:40
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 101-500 This PR causes between 101 and 500 packages to rebuild on Darwin. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Apr 19, 2026
@SFrijters
SFrijters requested a review from bobby285271 April 19, 2026 09:55
@SFrijters
SFrijters requested a review from romildo April 19, 2026 10:20
@SFrijters
SFrijters marked this pull request as ready for review April 19, 2026 14:37
@nixpkgs-ci
nixpkgs-ci Bot requested a review from Ericson2314 April 19, 2026 14:54
@SFrijters
SFrijters requested a review from ShamrockLee May 1, 2026 11:47
@SFrijters
SFrijters requested a review from alyssais May 17, 2026 13:21
@alyssais

Copy link
Copy Markdown
Member

Making it work for all outputs seems like an improvement regardless, but it's not great that we can't get outputs in order any more… that means there's no way to get the default output?

@alyssais

Copy link
Copy Markdown
Member

So overall makes sense. Would be nice to see the associative array version.

@SFrijters
SFrijters force-pushed the wrap-gapps-hook-staging branch from 1a75510 to 3d8860f Compare May 18, 2026 10:39
@SFrijters

SFrijters commented May 18, 2026 •

Copy link
Copy Markdown
Member Author

Pushed a new version using an associative array - apparently we need a -g flag on the declaration to have it persist between function calls (contents verified by inserting some echo statements and seeing the array grow as multiple outputs are processed).

Making it work for all outputs seems like an improvement regardless, but it's not great that we can't get outputs in order any more… that means there's no way to get the default output?

I'm not sure - it makes sense that the order is lost inside the associative array, but I also don't immediately see a separate variable to keep track of the default. There is some logic in pkgs/build-support/setup-hooks/multiple-outputs.sh for selecting the correct name for various outputs, maybe that could be extended for "default output" / lifted to stdenv setup.sh to some extent?

Edit: output handling for __structuredAttrs was added in #175649 - before my time!

@SFrijters
SFrijters force-pushed the wrap-gapps-hook-staging branch from 3d8860f to c80428c Compare May 18, 2026 10:46
This hook is called in the fixupPhase via

```
local output
for output in $(getAllOutputNames); do
  prefix="${!output}" runHook fixupOutput
done
```

Without `__structuredAttrs`, `getAllOutputNames` returns the `output` array, in order.
However, with `__structuredAttrs`, it returns the keys of the `output` associative array,
which are no longer necessarily ordered in the same way.

In the case of some packages (e.g. `mate-panel-with-applets`) this means that instead of
`[ "out" "man" ]`, we process `[ "man" "out" ]`. Running the hook for `"man"` then sets
`wrapGAppsHookHasRun` and no wrapping is done for `"out"`, which is what was really needed.

Instead, keep track of whether the hook has run on a per-output basis. That way, the order
does not matter and any executables that are spread around multiple outputs are wrapped.
@SFrijters
SFrijters force-pushed the wrap-gapps-hook-staging branch from c80428c to a0ee897 Compare May 18, 2026 13:34
@nixpkgs-ci nixpkgs-ci Bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label May 18, 2026
@SFrijters

Copy link
Copy Markdown
Member Author

Also tested this commit and this commit + #523612 applied to master with nix-build -A nixosTests.mate.

@SFrijters
SFrijters added this pull request to the merge queue May 24, 2026
Merged via the queue into NixOS:staging with commit 128c058 May 24, 2026
29 of 31 checks passed
@SFrijters
SFrijters deleted the wrap-gapps-hook-staging branch May 24, 2026 13:04
SFrijters added a commit to SFrijters/nixpkgs that referenced this pull request May 27, 2026
This partially reverts commit 72a37f9.
Requires NixOS#511330 .
SFrijters added a commit to SFrijters/nixpkgs that referenced this pull request May 27, 2026
@nekowinston nekowinston mentioned this pull request Jun 1, 2026
3 of 14 tasks
@jtojnar

jtojnar commented Jun 1, 2026

Copy link
Copy Markdown
Member

@jtojnar

jtojnar commented Jun 1, 2026

Copy link
Copy Markdown
Member

Actually, maybe we want to skip lib output by default/handle only out & bin to prevent cycles like #526575.

@nixpkgs-ci

nixpkgs-ci Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Successfully created backport PR for release-26.05:

@github-actions github-actions Bot added the 8.has: port to stable This PR already has a backport to the stable release. label Jul 27, 2026
@booxter booxter added backport staging-26.05 Backport PR automatically and removed backport release-26.05 Backport PR automatically labels Jul 27, 2026
@nixpkgs-ci

nixpkgs-ci Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Successfully created backport PR for staging-26.05:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

8.has: port to stable This PR already has a backport to the stable release. 10.rebuild-darwin: 101-500 This PR causes between 101 and 500 packages to rebuild on Darwin. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 12.approvals: 1 This PR was reviewed and approved by one person. backport staging-26.05 Backport PR automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants