Repository navigation
fix: don't require inputs.nixos-wsl when WSL is unused - #703
Merged
Merged
Conversation
sini
approved these changes
Sep 26, 2026
sini
added a commit
that referenced
this pull request
Nov 6, 2026
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:
```nix
(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.
Co-authored-by: Jason Bowman <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #702.
The
host.wsl.moduledefault unconditionally readsinputs.nixos-wsl, so any flake without that input fails evaluation even with WSL disabled everywhere (and even with an explicithost.wsl.modulevalue, since the default itself gets forced during option checking).This falls back to an empty module when the input is absent. WSL users are unaffected (input present -> same module as before); enabling WSL without the input still errors, just later at the missing
wsl.enableoption instead of at den evaluation.Verified against my own flake (no
nixos-wslinput): before,nix eval .#nixosConfigurations.laptop...failed withattribute 'nixos-wsl' missing; with this patch it evaluates to the system drv.