modules/extraFiles: refactor to use symlinks and support directories #4016
+264
−31
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.
Summary
This PR refines the
extraFilesoption to support directory sources, ensure deterministic conflict detection, and expand the test suite. This makesextraFilesmore predictable, more flexible, and less wasteful in the Nix store.Key improvements
1. Directory support
extraFilesentries may now specify a directory as their source.The directory is symlinked into the final output as-is, allowing structured layouts without requiring users use
builtins.readDir.2. Deterministic conflict detection
The build now validates the merged set of targets and reports conflicts early.
It detects:
Duplicate targets
File vs directory conflicts
file→directoryanddirectory→file) are rejected.Prefix conflicts
fooandfoo/barsimultaneously.This ensures module merges behave consistently regardless of evaluation order.
3. Store-efficient output
Sources are now installed using symlinks rather than copying.
This avoids unnecessary Nix store duplication and matches current behaviour in the NixOS
/etcmodule.4. Expanded and consolidated tests
The test suite now includes coverage for:
Fixes #3992
cc @daniellaing