aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJade Lovelace <lix@jade.fyi>2024-05-22 16:58:35 -0700
committerJade Lovelace <lix@jade.fyi>2024-05-22 17:08:37 -0700
commitd05e0b9f1fedfe1700959cc6045ce9bc25b9e955 (patch)
tree51c37f6400b8a3cada205e41bd576762e275c564
parent06c1375e52926be4455762ece825589fda86c942 (diff)
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: https://git.lix.systems/lix-project/lix/issues/337 Change-Id: I49197bfb4db55b082f914f0d70e84f5f5f110954
-rw-r--r--src/libcmd/repl.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc
index 525c25560..89691d33a 100644
--- a/src/libcmd/repl.cc
+++ b/src/libcmd/repl.cc
@@ -90,7 +90,8 @@ struct NixRepl
Strings loadedFiles;
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;
Env * env;
int displ;
@@ -854,6 +855,11 @@ void NixRepl::loadReplOverlays()
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);
}