Skip to content

Make module packages the devShell interface - #516

Merged
rahultee merged 3 commits into
mainfrom
victor/flake-devshell-modules
Nov 5, 2026
Merged

rahultee merged 3 commits into
mainfrom
victor/flake-devshell-modules

Conversation

@vlinkz

@vlinkz vlinkz commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Watch or download the recording

Why

devShells.x86_64-linux.default = pkgs.mkShell {
  packages = [ nm.nodejs-24 nm."python-3.12" pkgs.ffmpeg ];
};

What changed

  • packages.<id> is now the module's shell package instead of its JSON. Its setup hook prepends to shellHook, so the module's env vars and PATH are applied when the shell starts (not when nix captures the env in the build sandbox), and share/replit/modules (which holds <id>.json) is added to REPLIT_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.
  • Removed lib.mkToolchain, its env helper, shellPackages, deploymentShellPackages, and the shell.<id> / deployment-shell.<id> package attributes. Deployments keep reading module JSON.
  • checks.flake-toolchain is now checks.module-shell (pkgs/moduleit/tests.nix). It keeps the env-escaping, laziness and bundle API assertions, and adds checks for REPLIT_MODULES, two modules in one shell, and the dev/deployment closures.

Test plan

  • nix fmt -- --check . and nix build .#checks.x86_64-linux.module-shell pass.
  • nix develop on the flake above, pointed at this branch: node v24.22.1, Python 3.12.12 and ffmpeg are on PATH, and REPLIT_MODULES contains nodejs-24.json and python-3.12.json (language servers typescript-language-server and ty).
  • REPL_HOME=/tmp/realhome nix develop keeps that REPL_HOME (and XDG_CONFIG_HOME=/tmp/realhome/.config); unset, it defaults to the shell's working directory. Module PATH entries come before stdenv's, and nix print-dev-env runs the same shellHook.
  • The full scripts/ci_check.sh was not run locally.

Rollout

  • Removes lib.mkToolchain, shellPackages and deploymentShellPackages, and changes what packages.<id> builds (a directory with the setup hook and JSON instead of the JSON file). The JSON alone is still at modules.<id>, for example nix build .#'modules."nodejs-24"'. No callers were found in goval or repl-it-web, and an org code search found no mkToolchain users. 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 its shellHook when loading it; the print-dev-env script already does. Readers of nix print-dev-env --json or builds that use these packages as inputs get no module env.

  • Support extra packages in flake toolchains #513 extends mkToolchain and conflicts with this.

  • This is fully backward and forward compatible

~ written by ⠕ Replit

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
@vlinkz
vlinkz requested a review from a team as a code owner November 5, 2026 19:58
@vlinkz
vlinkz requested review from airportyh and removed request for a team November 5, 2026 19:58
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
@vlinkz
vlinkz requested a review from rahultee November 5, 2026 20:34
@rahultee
rahultee merged commit ca9e0a3 into main Nov 5, 2026
@rahultee
rahultee deleted the victor/flake-devshell-modules branch November 5, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants