Repository navigation
Make module packages the devShell interface - #516
Merged
Merged
Conversation
A repl flake now lists modules directly in mkShell: packages = [ nm.nodejs-24 nm."python-3.12" pkgs.ffmpeg ]; packages.<id> is the module's shell package instead of its JSON. Its setup hook exports the module env and PATH, and appends share/replit/modules (holding <id>.json) to REPLIT_MODULES, so the IDE reads metadata from the shell's env and the JSON's store references keep LSPs and runners in the closure. Remove lib.mkToolchain, its env helper, shellPackages and the deployment shells: the devShell replaces them, and deployments keep reading module JSON. The toolchain check becomes a module-shell check over the shell packages and bundle API. Assisted-by: Replit
The setup hook exported the module env while nix captured the shell environment in the build sandbox, so REPL_HOME and everything derived from it became the build directory, and module PATH entries landed after stdenv's. The hook now prepends a source of the env script to shellHook, which nix develop and print-dev-env run in the user's shell. The first-listed module wins for PATH and plain variables. Assisted-by: Replit
Assisted-by: Replit
rahultee
approved these changes
Nov 5, 2026
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.
Watch or download the recording
Why
mkShellpackages, with no nixmodules library call (design doc). Add pinned flake toolchain and shell outputs #509 put module selection inlib.mkToolchain { moduleIds; }, so the toolchain builds the shell and the repl flake has to expose a second output.What changed
packages.<id>is now the module's shell package instead of its JSON. Its setup hook prepends toshellHook, so the module's env vars and PATH are applied when the shell starts (not when nix captures the env in the build sandbox), andshare/replit/modules(which holds<id>.json) is added toREPLIT_MODULES. The first-listed module wins for PATH and plain variables. The IDE can read module metadata from the shell's env, and the JSON's store references keep LSPs and runners in the closure.lib.mkToolchain, its env helper,shellPackages,deploymentShellPackages, and theshell.<id>/deployment-shell.<id>package attributes. Deployments keep reading module JSON.checks.flake-toolchainis nowchecks.module-shell(pkgs/moduleit/tests.nix). It keeps the env-escaping, laziness and bundle API assertions, and adds checks forREPLIT_MODULES, two modules in one shell, and the dev/deployment closures.Test plan
nix fmt -- --check .andnix build .#checks.x86_64-linux.module-shellpass.nix developon the flake above, pointed at this branch:nodev24.22.1, Python 3.12.12 andffmpegare on PATH, andREPLIT_MODULEScontainsnodejs-24.jsonandpython-3.12.json(language serverstypescript-language-serverandty).REPL_HOME=/tmp/realhome nix developkeeps thatREPL_HOME(andXDG_CONFIG_HOME=/tmp/realhome/.config); unset, it defaults to the shell's working directory. Module PATH entries come before stdenv's, andnix print-dev-envruns the sameshellHook.scripts/ci_check.shwas not run locally.Rollout
Removes
lib.mkToolchain,shellPackagesanddeploymentShellPackages, and changes whatpackages.<id>builds (a directory with the setup hook and JSON instead of the JSON file). The JSON alone is still atmodules.<id>, for examplenix build .#'modules."nodejs-24"'. No callers were found in goval or repl-it-web, and an org code search found nomkToolchainusers.modules,deploymentModules, the bundle and the module JSON are unchanged.Consumers that save the shell env (for example replenv with
nix develop --profile) must run itsshellHookwhen loading it; theprint-dev-envscript already does. Readers ofnix print-dev-env --jsonor builds that use these packages as inputs get no module env.Support extra packages in flake toolchains #513 extends
mkToolchainand conflicts with this.This is fully backward and forward compatible
~ written by ⠕ Replit