feat: enforce boundaries by simulating pure eval #7
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.
With this, we have essentially achieved NixOS/nix#6530 in pure nix. In fact, we are a bit "more pure" since we don't allow arbitrary imports (instead all code must be a module member somewhere) and we don't allow referencing arbitrary paths (modules can only access the (non-nix) files in their own directory through "${mod}"`. We also disable the builtin fetchers to encourage users to declare their dependencies statically in the manifest, and also because those fetchers block evaluation (and therefore builds).
The only remaining "impurity" in this sense would be the path passed to the composer function, but this impurity is actually a good thing, since it doesn't eagerly copy everything to the nix store like flakes, but instead only makes pure (/nix/store) copies of files when they are actually accessed.
If the path doesn't exist on the file-system we will immediately fail anyway, so it's "impurity" is irrelevant. With these added restrictions, there will be no way for the user to escape the module system, so that means that we basically have a totally pure nix evaluation without the high cost of having to copy the entire repo into the /nix/store eagerly.