fix: enlarge envSize by several times to not be close to nixpkgs size

nixpkgs has 23000 attributes, and our previous limit would be hit if you
have more than one nixpkgs in the environment, for example, because
`repl-overlays` will load the new stuff from the environment on top of
the existing environment.

This is not really testable since if we did write such a test, it would
just be testing this constant tbh...

Fixes: lix-project/lix#337
Change-Id: I49197bfb4db55b082f914f0d70e84f5f5f110954
This commit is contained in:
jade 2024-05-22 16:58:35 -07:00
parent 06c1375e52
commit d05e0b9f1f

View file

@ -90,7 +90,8 @@ struct NixRepl
Strings loadedFiles; Strings loadedFiles;
std::function<AnnotatedValues()> getValues; std::function<AnnotatedValues()> getValues;
const static int envSize = 32768; // Uses 8MiB of memory. It's fine.
const static int envSize = 1 << 20;
std::shared_ptr<StaticEnv> staticEnv; std::shared_ptr<StaticEnv> staticEnv;
Env * env; Env * env;
int displ; int displ;
@ -854,6 +855,11 @@ void NixRepl::loadReplOverlays()
replInitFilesFunction->determinePos(noPos) replInitFilesFunction->determinePos(noPos)
); );
// n.b. this does in fact load the stuff into the environment twice (once
// from the superset of the environment returned by repl-overlays and once
// from the thing itself), but it's not fixable because clearEnv here could
// lead to dangling references to the old environment in thunks.
// https://git.lix.systems/lix-project/lix/issues/337#issuecomment-3745
addAttrsToScope(newAttrs); addAttrsToScope(newAttrs);
} }