Skip to content

fix(batteries): give the wsl-host scope its own id - #745

Merged
sini merged 2 commits into
denful:mainfrom
istvnurbn:fix/wsl-host-scope-id
Nov 6, 2026
Merged

sini merged 2 commits into
denful:mainfrom
istvnurbn:fix/wsl-host-scope-id

Conversation

@istvnurbn

Copy link
Copy Markdown
Contributor

A host with wsl.enable = true gets a wsl-host child scope with the same scope id as the host. Pipes then go wrong for that host:

  • other hosts' pipe.collectAll misses its data;
  • it sees its own pool twice.

Reproduction

templates/ci/modules/deadbugs/wsl-host-scope-id.nix: two hosts each publish one tag and collect every host's tag. iceberg uses the wsl battery, with a stub in place of NixOS-WSL.

expected: { iceberg = ["iceberg","igloo"]; igloo = ["iceberg","igloo"]; }
actual:   { iceberg = ["iceberg","iceberg","igloo","igloo"]; igloo = ["igloo"]; }

It fails on main, and on v0.19.0 once #703 is applied (v0.19.0 predates it). It passes with wsl.enable = false.

Cause

host-to-wsl-host resolves the child with only host bound:

(den.lib.policy.resolve.to "wsl-host" { inherit host; })

mkScopeId builds an id from the context alone, so the child's id is the host's (host=iceberg). scopeEntityKind then records that id as wsl-host, so findMatchingAll drops it from ({ host, ... }: true) matches, and the pipe runs twice under it.

Fix

The child scope gets a binding of its own, the way system-to-flake-parts does, so its id becomes host=iceberg,wsl-host=iceberg.

Removing the resolve.to line also made the reproduction pass, but I haven't checked what else relies on the wsl-host scope. If you'd rather fix this in mkScopeId, for any resolve.to that adds no binding, I can rework it.

Checked

On NixOS with Nix 2.34.9, against main at 2f1ae4a:

Check main main + fix
deadbugs.wsl-host-scope-id fails passes
just ci-deep passes passes
just fmt no changes
just unit (checkmate) passes

The same test as a bogus bug.nix fails on main and on v0.19.0 + #703, and passes with wsl.enable = false or with the fix.

On my own config, which has a NixOS-WSL host, the fix leaves the system derivation of that host and of a non-WSL host unchanged. I also have an SSH key roster built on pipe.collectAll. Before the fix, the other hosts missed the WSL host's key and the WSL host got every key twice; with the fix, every host gets each key once.

AI-assisted: the analysis and the patch were drafted with Claude. I reproduced and checked everything above on my own machine.

@istvnurbn
istvnurbn requested a review from sini as a code owner November 6, 2026 08:28
@sini sini added the allow-ci allow all CI integration tests label Nov 6, 2026
@sini
sini enabled auto-merge (squash) November 6, 2026 19:27
@sini
sini merged commit bf2504f into denful:main Nov 6, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

allow-ci allow all CI integration tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants